我有以下的列族在卡桑德拉存儲在少數非常「寬」行的時間序列數據「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