Search code examples
cassandrahector

Get multiple column ranges from one row in Cassandra via Hector


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?


Solution

  • 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.