Peter
Peter

Reputation: 2759

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

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 ?

Upvotes: 0

Views: 208

Answers (1)

Chris Lohfink
Chris Lohfink

Reputation: 16400

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);

Upvotes: 0

Related Questions