cassandra : Is there a way to get all value of columns starting with a particular prefix?

219 Views Asked by At

I need to get all column:column_value pairs for a key. the constraint is columns have a common Prefix , is there a way to get it using Hector ?

1

There are 1 best solutions below

2
On

you can do a SliceQuery, and do a range from the prefix to prefix|, providing its only alphanumerics that should work.

StringSerializer ss = StringSerializer.get();
SliceQuery sliceQuery = HFactory.createSliceQuery(keySpace, rowSerializer, ss, ss);
sliceQuery.setColumnFamily(MY_COLUMN_FAMILY);
sliceQuery.setKey(rowKey);
sliceQuery.setRange("prefix", "prefix|", false, Integer.MAX_INT);