Hector:hector-core-1.0-5 Cassandra-1.1.2
我需要在Hector中为查询建模,如:
select * from table1 where rowkey='x' and secondary_indexed_column='y'
如果我使用将setStartKey设置为rowKey'x'的IndexedSliceQuery,我仍然会获得包含secondary_indexed_column ='y'的所有行。 如果我在addEqualsExpression(“row_key”,“x”)中添加row_key字段,我会得到以下异常:
org.apache.thrift.protocol.TProtocolException: Required field 'value' was not present! Struct: IndexExpression(column_name:64 65 76 69 63 65 5F 69 64, op:EQ, value:null)
at org.apache.cassandra.thrift.IndexExpression.validate(IndexExpression.java:562)
at org.apache.cassandra.thrift.IndexExpression.write(IndexExpression.java:499)
at org.apache.cassandra.thrift.IndexClause.write(IndexClause.java:521)
at org.apache.cassandra.thrift.Cassandra$get_indexed_slices_args.write(Cassandra.java:13469)
at org.apache.cassandra.thrift.Cassandra$Client.send_get_indexed_slices(Cassandra.java:793)
at org.apache.cassandra.thrift.Cassandra$Client.get_indexed_slices(Cassandra.java:781)
at me.prettyprint.cassandra.service.KeyspaceServiceImpl$19.execute(KeyspaceServiceImpl.java:732)
那么,如何限制indexedSliceQuery仅返回给定行键的结果?
答案 0 :(得分:0)
另一种选择是,如果您有分区数据,则可以在playOrm中执行此查询,该查询支持分区中的数百万行(尽管不超过1000万行)以及表中所需的多个分区。然后你只需要进行查询
@NoSqlQuery(name =“findSomething”,query =“PARTITIONS t(:partitionId)SELECT t FROM TABLE as t WHERE date>:some and yyyy<:second”)
注意:请注意查询没有限制,除非它在分区内并且您也可以进行JOINS !!!!