1
votes

Given I have one row in Cassandra with multiple columns that have an Integer as key and some value. Using SliceQuery in Hector gives me the ability to get one range of this columns. Is there a possibility to get multiple ranges with one query?

Example cassandra row:

columns 3, 7, 12, 34, 45, 46, 59, 98, 99
----------------------------------------
values  a, f,  e,  v,  a,  r,  r,  o,  k

How do I use Hector to get all columns with keys from 20 to 30 and 50 to 90 in one query?

2

2 Answers

3
votes

To solve that on PlayOrm open source project we do this...

Does Hector have the async calls like astyanax does so that you can do this

for(Query q : queryList) {
// this next call is non-blocking..sends requests and returns immediately not waiting for response
   Future f = q.executeAsycn(); 
   futures.add(f);
}

//Now, both column slices are happening in parallel at the SAME time

for(Future f : futures) {
   Result r = f.get(); //this will block for the first result
}

In this way, it is just as fast as if the api had ONE single api call anyways so no need for one call.

Dean

2
votes

I don't think so. To keep it in one query you'll have to use a single slice that includes all of the slices of interest and then on the client side decide on a column by column basis whether the columns fall into one of the ranges you're interested in.

You should note that if there's too much data to handle all of the columns in that one big slice in a single call, then you can use pagination to reduce the footprint of the data on the client side, but then you might as well just make individual calls for each of your original slices.