Example #1
0
 /**
  * Batch executes all mutations scheduled to this Mutator instance by addInsertion, addDeletion
  * etc. May throw a HectorException which is a RuntimeException.
  *
  * @return A MutationResult holds the status.
  */
 @Override
 public MutationResult execute() {
   if (pendingMutations == null || pendingMutations.isEmpty()) {
     return new MutationResultImpl(true, 0, null);
   }
   final BatchMutation<K> mutations = pendingMutations.makeCopy();
   pendingMutations = null;
   return new MutationResultImpl(
       keyspace.doExecute(
           new KeyspaceOperationCallback<Void>() {
             @Override
             public Void doInKeyspace(KeyspaceService ks) throws HectorException {
               ks.batchMutate(mutations);
               return null;
             }
           }));
 }
Example #2
0
 /**
  * Deletes a subcolumn of a supercolumn
  *
  * @param <SN> super column type
  * @param <N> subcolumn type
  */
 @Override
 public <SN, N> MutationResult subDelete(
     final K key,
     final String cf,
     final SN supercolumnName,
     final N columnName,
     final Serializer<SN> sNameSerializer,
     final Serializer<N> nameSerializer) {
   return new MutationResultImpl(
       keyspace.doExecute(
           new KeyspaceOperationCallback<Void>() {
             @Override
             public Void doInKeyspace(KeyspaceService ks) throws HectorException {
               ks.remove(
                   keySerializer.toByteBuffer(key),
                   ThriftFactory.createSuperColumnPath(
                       cf, supercolumnName, columnName, sNameSerializer, nameSerializer));
               return null;
             }
           }));
 }
Example #3
0
 @Override
 public String toString() {
   return "Mutator(" + keyspace.toString() + ")";
 }
Example #4
0
 /** {@inheritDoc} */
 @Override
 public <N> Mutator<K> addDeletion(K key, String cf, N columnName, Serializer<N> nameSerializer) {
   addDeletion(key, cf, columnName, nameSerializer, keyspace.createClock());
   return this;
 }
Example #5
0
 /**
  * Deletes the columns defined in the HSuperColumn. If there are no HColumns attached, we delete
  * the whole thing.
  */
 public <SN, N, V> Mutator<K> addSubDelete(K key, String cf, HSuperColumn<SN, N, V> sc) {
   return addSubDelete(key, cf, sc, keyspace.createClock());
 }