Java Cassandra 2 Hector:复合行键上的范围切片查询返回空行
我们正在使用ByteOrderedPartitioner为一个新项目存储时间序列,cql3对我们来说只是暂时的好消息,然后我们选择Hector继续,但现在我们的范围查询不起作用 C*版本:2.0.7 赫克托版本:1.0-5 模式:Java Cassandra 2 Hector:复合行键上的范围切片查询返回空行,java,cassandra,hector,Java,Cassandra,Hector,我们正在使用ByteOrderedPartitioner为一个新项目存储时间序列,cql3对我们来说只是暂时的好消息,然后我们选择Hector继续,但现在我们的范围查询不起作用 C*版本:2.0.7 赫克托版本:1.0-5 模式: ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition( keyspaceName, columnFamilyName,
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
=>(name=column1,value=AAL,timestamp=1401745673543000)
=>(名称=列2,值=纽约市,时间戳=1401745673543002)
罗基:100:20:12
=>(name=column1,value=AAL,timestamp=1401745673543000)
=>(名称=列2,值=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());
Composite startComposite=new Composite();
startComposite.addComponent(0100,等同于);
startComposite.addComponent(1,20,相等);
startComposite.addComponent(2,11,相等);
复合材料端复合材料=新复合材料();
endComposite.addComponent(0100,相等);
endComposite.addComponent(1,20,相等);
endComposite.addComponent(2,18,大于等于);
int rowCount=100;
RangeScileSquery RangeScileSquery=HFFactory
.CreateRangeS切片器(ksp,CompositeSerializer.get(),StringSerializer.get(),StringSerializer.get())
.setColumnFamily(columnFamilyName)
.setRange(“,”,false,行计数);
设置键(startComposite、endComposite);
QueryResult result=rangeSlicesQuery.execute();
System.out.println(result.get());
获取空行:
ColumnFamilyDefinition cfd = HFactory.createColumnFamilyDefinition(
keyspaceName, columnFamilyName,
ComparatorType.UTF8TYPE);
cfd.setComparatorTypeAlias("(IntegerType,IntegerType,IntegerType)");
cfd.setKeyValidationClass("CompositeType(IntegerType,IntegerType,IntegerType)");
cfd.setDefaultValidationClass(ComparatorType.UTF8TYPE.getClassName());
行({})这是一个卡桑德拉反模式。使用ByteOrderedPartitioner几乎没有什么好的理由,而这种模式不是其中之一。最终,所有写入和查询实际上都会命中一个节点(或少量节点,具体取决于集群大小)
Cassandra中有许多时间序列数据模型的好例子 你是对的,我一直在分析一个新的模式,它可以与Murruil3Partitioner一起运行,我得到了一些新的东西我们改变了它,因为我们的CQL3查询使用令牌函数来检查所有请求的行键:token(year_month,day)>=token(201404,20)和token(year_month,day),关于如何分页所有行。不能使用随机分区器在某个范围内翻页,因为键没有排序。如果要执行此操作,需要编写一个查询,该查询包含范围内的所有已知键,使用
SELECT*FROM ks.table WHERE mykey in(v1、v2、v3)
。由于键是月/日/年,因此计算起来应该很简单。