Database Reference
In-Depth Information
ColumnPath colPath = new ColumnPath();
colPath.column_family = columnFamily;
colPath.column = "b".getBytes();
client.remove(key, colPath, clock, ConsistencyLevel.ALL);
System.out.println("Remove done.");
conn.close();
Batch Mutates
There were many examples of using batch mutate to perform multiple inserts in Chapter 4 , so I
won't rehash that here. I'll just present an overview.
To perform many insert or update operations at once, use the batch_mutate method instead of
the insert method. Like a batch update in the relational world, the batch_mutate operation al-
lows grouping calls on many keys into a single call in order to save on the cost of network round
trips. If batch_mutate fails in the middle of its list of mutations, there will be no rollback, so
any updates that have already occured up to this point will remain intact. In the case of such a
failure, the client can retry the batch_mutate operation.
NOTE
There used to be an operation called batch_insert , but it is deprecated.
Batch Deletes
The sample application doesn't include any delete operations, so let's look at that in a little more
depth.
You use remove to delete a single column, but you can use a Deletion structure with a
batch_mutate operation to perform a set of complex delete operations at once.
You can create a list of column names that you want to delete, and then indirectly pass it to
batch_mutate . I say “indirectly” because there are several data structures that you need to cre-
ate in order to run a deletion.
First, create the list of column names to delete. Pass that list to a SlicePredicate , pass the
SlicePredicate to a Deletion object, pass that to a Mutation object, and finally, pass that to
a batch_mutate .
Search WWH ::




Custom Search