5
我有一個列族AllLog
創建插入卡桑德拉列族與複合鍵
create column family LogData
with column_type = 'Standard'
and comparator = 'CompositeType(org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type)'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'CompositeType(UTF8Type,UTF8Type)';
但是當我使用突變插入:
String key0 = "key0";
String key1 = "key1";
Composite compositeKey = new Composite();
compositeKey.addComponent(key0, StringSerializer.get());
compositeKey.addComponent(key1, StringSerializer.get());
// add
mutator.addInsertion(compositeKey, columnFamilyName, HFactory.createColumn("name", "value"));
mutator.execute();
始終貫穿例外:
me.prettyprint.hector.api.exceptions.HInvalidRequestException:
InvalidRequestException(why:Not enough bytes to read value of component 0)
請有人幫助我,在這段代碼中我的錯誤在哪裏?
是的,我知道,但我想知道的是:有,我可以創建一個表具有複合鍵的任何解決方案等欄是使用UTF8類型????我嘗試在cql3是okie但赫克託,我不能插入數據到這樣的表:(:( –
不知道你問什麼...在這裏用指定的模式,您應該更新代碼,以便createColumn使用複合名稱,否則修改模式以使比較器爲utf8。 – libjack