【发布时间】:2014-07-24 09:47:49
【问题描述】:
我们正在使用 ByteOrderedPartitioner 存储新项目的时间序列,cql3 对我们来说还不错,然后我们选择 Hector 继续前进,但现在我们的范围查询不起作用。
C* 版本:2.0.7
赫克托版本: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());
行键:100:20:11
=>(名称=column1,值=AAL,时间戳=1401745673543000)
=>(名称=column2,值=NYC,时间戳=1401745673543002)
行键:100:20:12
=>(名称=column1,值=AAL,时间戳=1401745673543000)
=>(名称=column2,值=TXA,时间戳=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());
获取空行:
行({})
【问题讨论】: