3
我在嘗試使用2列組合鍵查詢列族(CF)時遇到問題:comment_key
和prattle_key
。Cassandra的新增功能 - SliceQuery給出錯誤沒有足夠的字節來讀取組件0的值
下面是CF的定義:
CREATE TABLE comments (
comment_key text,
prattle_key text,
parent_key text,
depth int,
author text,
date_created timestamp,
body text,
PRIMARY KEY (comment_key, prattle_key)
) WITH
comment='' AND
caching='KEYS_ONLY' AND
read_repair_chance=0.100000 AND
gc_grace_seconds=864000 AND
replicate_on_write='true' AND
compaction_strategy_class='SizeTieredCompactionStrategy' AND
compression_parameters:sstable_compression='SnappyCompressor';
這是我的Java代碼:
Composite key = new Composite();
key.addComponent(prattleKey, StringSerializer.get());
key.addComponent(commentKey, StringSerializer.get());
SliceQuery<Composite, String, String> query = HFactory.createSliceQuery(keyspace, CompositeSerializer.get(), StringSerializer.get(), StringSerializer.get());
query.setColumnFamily("comments").setKey(key).setColumnNames("parent_key", "body", "depth", "date", "author");
QueryResult<ColumnSlice<String, String>> queryResult = query.execute();
ColumnSlice<String, String> cs = queryResult.get();
我收到以下錯誤信息:
InvalidRequestException(why:Not enough bytes to read value of component 0)
使用命令行CQL工具,我可以選擇ColumnFamily中的所有3行,所以我知道那裏有數據。
任何援助將不勝感激!謝謝!