2012-06-25 67 views
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) 

请有人帮助我,在这段代码中我的错误在哪里?

回答

2

模式规定比较器作为一个复合型的,但插入创建具有单个字符串(“名称”)的列。

+0

是的,我知道,但我想知道的是:有,我可以创建一个表具有复合键的任何解决方案等栏是使用UTF8类型????我尝试在cql3是okie但赫克托,我不能插入数据到这样的表:(:( –

+0

不知道你问什么...在这里用指定的模式,您应该更新代码,以便createColumn使用复合名称,否则修改模式以使比较器为utf8。 – libjack