Skip to content

Commit

Permalink
Merge pull request #662 from horschi/master
Browse files Browse the repository at this point in the history
added range deletes to hector
  • Loading branch information
zznate committed Apr 11, 2014
2 parents 464365e + 3e167a9 commit 0c760d9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
22 changes: 22 additions & 0 deletions core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.prettyprint.cassandra.model;

import java.nio.ByteBuffer;
import java.util.Arrays;

import me.prettyprint.cassandra.model.thrift.ThriftConverter;
Expand All @@ -18,6 +19,7 @@
import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.Deletion;
import org.apache.cassandra.thrift.SlicePredicate;
import org.apache.cassandra.thrift.SliceRange;



Expand Down Expand Up @@ -228,6 +230,26 @@ public <N> Mutator<K> addDeletion(K key, String cf, N columnName, Serializer<N>
return this;
}

/**
* {@inheritDoc}
*/
@Override
public <N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer) {
return addDeletion(key, cf, columnNameStart, columnNameFinish, nameSerializer, keyspace.createClock());
}

/**
* {@inheritDoc}
*/
@Override
public <N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer, long clock) {
SlicePredicate sp = new SlicePredicate();
sp.setSlice_range(new SliceRange(nameSerializer.toByteBuffer(columnNameStart), nameSerializer.toByteBuffer(columnNameFinish), false, Integer.MAX_VALUE));
Deletion d = new Deletion().setTimestamp(clock).setPredicate(sp);
getPendingMutations().addDeletion(key, Arrays.asList(cf), d);
return this;
}

/**
* Batch executes all mutations scheduled to this Mutator instance by addInsertion, addDeletion etc.
* May throw a HectorException which is a RuntimeException.
Expand Down
27 changes: 27 additions & 0 deletions core/src/main/java/me/prettyprint/hector/api/mutation/Mutator.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,33 @@ <SN> MutationResult superDelete(K key, String cf, SN supercolumnName,
*/
<N> Mutator<K> addDeletion(K key, String cf, N columnName, Serializer<N> nameSerializer, long clock);

/**
* Adds a Range-Deletion to the underlying batch_mutate call.
*
* @param <N> column name type
* @param key row key
* @param cf column family
* @param columnNameStart starting column name. Cannot be null.
* @param columnNameFinish end column name. Cannot be null.
* @param nameSerializer a name serializer
* @return a mutator
*/
<N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer);

/**
* Adds a Range-Deletion to the underlying batch_mutate call.
*
* @param <N> column name type
* @param key row key
* @param cf column family
* @param columnNameStart starting column name. Cannot be null.
* @param columnNameFinish end column name. Cannot be null.
* @param nameSerializer a name serializer
* @param clock custom clock to use in the deletion
* @return a mutator
*/
<N> Mutator<K> addDeletion(K key, String cf, N columnNameStart, N columnNameFinish, Serializer<N> nameSerializer, long clock);


<SN,N,V> Mutator<K> addSubDelete(K key, String cf, HSuperColumn<SN,N,V> sc);

Expand Down

0 comments on commit 0c760d9

Please sign in to comment.