加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-13 13:29:39 所属栏目:百科 来源:网络整理
导读:我有一个列族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 = 'UTF8Typ
我有一个列族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”)的列.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读