nosql – 使用复合键插入cassandra列族

前端之家收集整理的这篇文章主要介绍了nosql – 使用复合键插入cassandra列族前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个列族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)';

但是当我使用mutator插入时:

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)

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

解决方法

模式将比较器指定为复合类型,但插入会创建一个包含单个字符串(“name”)的列.

猜你在找的NoSQL相关文章