Cassandra复合 - 查询部分列

时间:2016-02-24 10:22:14

标签: cassandra composite-key astyanax

对于存储为DynamicCompositeColumns(Long,UTF8)的数据,如下所示,

rowkey: t1
column1: 1456394880000:test1:a1, value=...
column2: 1457273146000:test1:a3, value=....
column3: 1457273146000:test2:a3, value=...

1.如何获得与列的第二个组件值(例如test1)匹配的所有列,而不考虑第一个组件值。

以下相等比较不起作用。

    startComposite.addComponent(Long.MINVALUE, LongSerializer.get(), Operator.Equals));
    startComposite.addComponent("test1", StringSerializer.get(), Operator.Equals));

    endComposite.addComponent(Long.MAXVALUE, LongSerializer.get(), Operator.GreaterEquals)); 
    endComposite.addComponent("test1", StringSerializer.get(), Operator.GreaterEquals));

2。如何获得与component2&匹配的特定列component3值(例如test1& a3)

    startComposite.addComponent(Long.MINVALUE, LongSerializer.get(), Operator.Equals));
    startComposite.addComponent("test1", StringSerializer.get(), Operator.Equals));
    startComposite.addComponent("a3", StringSerializer.get(), Operator.Equals));

    endComposite.addComponent(Long.MAXVALUE, LongSerializer.get(), Operator.GreaterEquals)); 
    endComposite.addComponent("test1", StringSerializer.get(), Operator.EQUALS));
    endComposite.addComponent("a3", StringSerializer.get(), Operator.GreaterEquals));

0 个答案:

没有答案