javacassandrapelops

Java Pelops and Cassandra NoSQL DB: Can I Batch Delete Rows?


I'm trying to figure out how to batch delete rows in Cassandra DB using Pelops.

Ideally, I could specify a KeyRange of rows that need to be deleted. That would work fine for my purposes.

However, my (albeit brief) research is leading me to believe that this is not currently possible. RowDeletor only takes a rowKey, and not a KeyRange. Are these findings correct?

I should be able to do it programmatically using a modified version of one of my List functions, but, again, a KeyRange would be preferable.


Solution

  • No, I don't think you can batch delete rows with Pelops, its RowDeletor does not participate in batches, and the Mutator class only has deletion operations for explicitly named columns.

    If you take a look at the code for Pelops' deleteColumns you can see that it creates a deletion and adds it to the list of mutations, I think that just adding more deletions to that list would make them be issued in the same batch. The getMutationList method is protected, so perhaps you can make a subclass that either exposes that method, or has a way to add more deletions to the list.

    It looks like you can do it with Hector, its Mutator interface has methods that take multiple row keys, e.g. addDeletion(K key, String cf) and addDeletion(Iterable<K> keys, String cf). So Cassandra should at least support deleting multiple rows per batch.