我有以下的列族在卡桑德拉存储在少数非常“宽”行的时间序列数据“IN”的关系:复合柱和卡桑德拉
CREATE TABLE data_bucket (
day_of_year int,
minute_of_day int,
event_id int,
data ascii,
PRIMARY KEY (data_of_year, minute_of_day, event_id)
)
在CQL壳,我能够运行的查询如此:
select * from data_bucket where day_of_year = 266 and minute_of_day = 244
and event_id in (4, 7, 11, 1990, 3433)
实质上,我修复复合列名(minute_of_day)的第一个分量的值和要选择基于所述不同值的非连续的一组列的的第二个组件(event_id)。由于“IN”关系被解释为平等关系,所以这可以很好地工作。
现在我的问题是,我将如何以编程方式完成相同类型的组合列切片,而不使用CQL。到目前为止,我已经尝试过Python客户端pycassa和Java客户端Astyanax,但没有任何成功。
任何想法都会受到欢迎。
编辑:
我加入柱族的描述输出通过卡桑德拉-CLI看到。由于我正在寻找基于Thrift的解决方案,所以这可能会有所帮助。
ColumnFamily: data_bucket
Key Validation Class: org.apache.cassandra.db.marshal.Int32Type
Default column value validator: org.apache.cassandra.db.marshal.AsciiType
Cells sorted by: org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.Int32Type,org.apache.cassandra.db.marshal.Int32Type)
GC grace seconds: 864000
Compaction min/max thresholds: 4/32
Read repair chance: 0.1
DC Local Read repair chance: 0.0
Populate IO Cache on flush: false
Replicate on write: true
Caching: KEYS_ONLY
Bloom Filter FP chance: default
Built indexes: []
Compaction Strategy: org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy
Compression Options:
sstable_compression: org.apache.cassandra.io.compress.SnappyCompressor
你确定这个查询在卡桑德拉cqlsh作品?在卡桑德拉IN操作只支持分区键,在你的情况event_id仅仅是聚类列。 – abhi
@abhi它当然可以工作。我的理解是,只要所有先前的组件指定了严格的平等关系,组合列的最后一个组件就可以指定一个范围/一列的列。看看这里:http://www.datastax.com/dev/blog/introduction-to-composite-columns-part-1 – Nikhil
@abhi在这里:http://cassandra.apache.org/doc/cql3/ CQL.html#selectStmt – Nikhil