Cassandra-0.8.1 使用批量突变时的限制

发布于 2024-11-19 19:08:35 字数 1432 浏览 6 评论 0原文

当我进行批量突变时,我发现卡桑德拉有一些例外,它说“这个突变已经有修改”,但给出的信息是两个不同的操作。 在这种情况下,我使用带计数器的超级列,就像

  • Key: md5 of urls, utf-8
  • SuperColumnName: date, utf-8
  • ColumnName: Counter name is a random number from 1 to 200,
  • ColumnValue:1L

L

public void SuperCounterMutation(ArrayList<String> urlList) {
    LinkedList<HCounterSuperColumn<String, String>> counterSuperColumns;
    for(String line : urlList) {
      String[] ele = StringUtils.split(StringUtils.strip(line), ':');
      String key = ele[0];
      String SuperColumnName = ele[1];
      LinkedList<HCounterColumn<String>> ColumnList = new LinkedList<HCounterColumn<String>>();
      for(int i = 2; i < ele.length; ++i) {
        ColumnList.add(HFactory.createCounterColumn(ele[i], 1L, ser));
      }
      mutator.addCounter(key, ColumnFamilyName, HFactory.createCounterSuperColumn(SuperColumnName, ColumnList, ser, ser));
      ++count;
      if(count >= BUF_MAX_NUM) {
        try {
          mutator.execute();
        } catch(Exception e) {
          e.printStackTrace();
        }   
        mutator = HFactory.createMutator(keyspace, ser);
        count = 0;
      }   
    }
    return;
}

来自 cassandra 日志的错误信息可以看出,重复的操作只有相同的key,SuperColumnName不一样,并且对于计数器名称设置,有的冲突有相交,有的不相交。

我正在使用 Cassandra 0.8.1 和 hector 0.8.0-rc2

谁能告诉我这个问题的原因?提前致谢!

I found some exceptions from cassandra when I do batch mutation, it said "already has modifications in this mutation", but the info given are two different operations.
I use Super column with counters in this case, it's like

  • Key: md5 of urls, utf-8
  • SuperColumnName: date, utf-8
  • ColumnName: Counter name is a random number from 1 to 200,
  • ColumnValue:1L

L

public void SuperCounterMutation(ArrayList<String> urlList) {
    LinkedList<HCounterSuperColumn<String, String>> counterSuperColumns;
    for(String line : urlList) {
      String[] ele = StringUtils.split(StringUtils.strip(line), ':');
      String key = ele[0];
      String SuperColumnName = ele[1];
      LinkedList<HCounterColumn<String>> ColumnList = new LinkedList<HCounterColumn<String>>();
      for(int i = 2; i < ele.length; ++i) {
        ColumnList.add(HFactory.createCounterColumn(ele[i], 1L, ser));
      }
      mutator.addCounter(key, ColumnFamilyName, HFactory.createCounterSuperColumn(SuperColumnName, ColumnList, ser, ser));
      ++count;
      if(count >= BUF_MAX_NUM) {
        try {
          mutator.execute();
        } catch(Exception e) {
          e.printStackTrace();
        }   
        mutator = HFactory.createMutator(keyspace, ser);
        count = 0;
      }   
    }
    return;
}

Error info from cassandra log showed that the duplicated operations have the same key only, SuperColumnName are not the same, and for counter name set, some conflicts have intersects and some not.

I'm using Cassandra 0.8.1 with hector 0.8.0-rc2

Can anyone tell me the reason of this problem? Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝梦月影 2024-11-26 19:08:35

来自cassandra日志的错误信息显示重复的操作具有相同的密钥

Bingo。您需要将同一键的操作合并到一个突变中。

Error info from cassandra log showed that the duplicated operations have the same key

Bingo. You'll need to combine operations from the same key into a single mutation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文