我们正在使用ByteOrderedPartitioner存储新项目的时间序列,cql3对我们来说只是片刻,然后我们选择Hector继续前进,但现在我们的范围查询不起作用。
C *版本:2.0.7
Hector版本:1.0-5
架构:
ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition(
keyspaceName, columnFamilyName,
ComparatorType.UTF8TYPE);
cfd.setComparatorTypeAlias("(IntegerType,IntegerType,IntegerType)");
cfd.setKeyValidationClass("CompositeType(IntegerType,IntegerType,IntegerType)");
cfd.setDefaultValidationClass(ComparatorType.UTF8TYPE.getClassName());
RowKey:100:20:11
=> (name = column1,value = AAL,timestamp = 1401745673543000)
=> (name = column2,value = NYC,timestamp = 1401745673543002)
RowKey:100:20:12
=> (name = column1,value = AAL,timestamp = 1401745673543000)
=> (name = column2,value = TXA,timestamp = 1401745673543002)
等等..
查询迭代cassandra列族的所有行
Composite startComposite = new Composite();
startComposite.addComponent(0,100,EQUAL);
startComposite.addComponent(1,20,EQUAL);
startComposite.addComponent(2,11,EQUAL);
Composite endComposite = new Composite();
endComposite.addComponent(0,100,EQUAL);
endComposite.addComponent(1,20, EQUAL);
endComposite.addComponent(2,18,GREATER_THAN_EQUAL);
int rowCount = 100;
RangeSlicesQuery<Composite, String, String> rangeSlicesQuery = HFactory
.createRangeSlicesQuery(ksp, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get())
.setColumnFamily(columnFamilyName)
.setRange("", "", false, rowCount);
rangeSlicesQuery.setKeys(startComposite, endComposite);
QueryResult<OrderedRows<Composite, String, String>> result = rangeSlicesQuery.execute();
System.out.println(result.get());
获取空行:
行({})
答案 0 :(得分:0)
这是一种Cassandra反模式。使用ByteOrderedPartitioner的原因很少,而且这种模式不是其中之一。您最终会遇到所有写入和查询基本上命中一个节点(或少量节点,具体取决于您的群集大小)。
Cassandra中有许多时间序列数据模型的好例子。 Here is one from Datastax