I have a composite column with two components (component1, component2), and I'd like to query where component1<=arg1 AND component2<=arg2. I assumed this could be achieved with the code below but I get an exception from Hector: "InvalidRequestException(why:Too many bytes for comparator)"
I'm new to Cassandra (and thus Hector) and I'm unsure if this type of Composite query is supported or if I'm even going about this the right way. I found tutorial code (https://github.com/zznate/cassandra-tutorial/blob/master/src/main/java/com/datastax/tutorial/StaticCompositeIndex.java) that has commented code setting ComponentEquality to GREATER_THAN_EQUAL, but when I uncomment and run it, I see the same exception.
public String query(long component1Value, long Component2Value) {
SliceQuery<String, Composite, String> sq = HFactory.createSliceQuery(keyspace, StringSerializer.get(), new CompositeSerializer(), StringSerializer.get());
sq.setColumnFamily(keyCF);
sq.setKey("x");
Composite startRange = new Composite();
startRange.addComponent(component1Value, LongSerializer.get(), "LongType", AbstractComposite.ComponentEquality.LESS_THAN_EQUAL);
startRange.addComponent(component2Value, LongSerializer.get(), "LongType", AbstractComposite.ComponentEquality.LESS_THAN_EQUAL);
sq.setRange(startRange, null, false, 1);
QueryResult<ColumnSlice<Composite,String>> result = sq.execute();
ColumnSlice<Composite, String> slice = result.get();
return slice.getColumns().get(0).getValue();
}
// The column family definition
create column family Key
with column_type = 'Standard'
and comparator = 'CompositeType(LongType(reversed=true), LongType(reversed=true))'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type'
and rows_cached = 0
and row_cache_save_period = 0
and row_cache_keys_to_save = 2147483647
and keys_cached = 1.0
and key_cache_save_period = 14400
and read_repair_chance = 0.1
and gc_grace = 864000
and min_compaction_threshold = 4
and max_compaction_threshold = 32
and replicate_on_write = true
and row_cache_provider = 'ConcurrentLinkedHashCacheProvider'
and compaction_strategy = 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy'
set Key[x]['0:0']=1;
set Key[x]['0:1']=2;
set Key[x]['1:1']=3;
With the above Java code, the desired result should be query(1, 0) returns the value "1" or the value corresponding to Key[x]['0:0'] because obviously that is the only column that satisfies component1 <= 1 AND component2 <= 0.
Environment is: Cassandra 1.0.5, Hector 1.0.2
