【问题标题】:Unable to use cassandra counter column with cassandra gem无法将 cassandra 计数器柱与 cassandra gem 一起使用
【发布时间】:2013-05-06 22:57:48
【问题描述】:

我通过使用 cqlsh 的以下命令创建了一个列族:

create table mystats (key PRIMARY KEY, count counter);

现在,我可以从 cqlsh 增加计数器列,但是当我尝试从 cassandra gem 执行此操作时,如下所示: Are there any Ruby clients for Cassandra with counters and supercolumn?

所以当我使用时:

@stats.add(:mystats, 'randomkey', 1, 'count')

我收到一个错误:

Cassandra::AccessError at /client 列族“mystats”无效

当我进一步研究它时,我发现错误是从 gem 中引发的: 在文件中:https://github.com/twitter/cassandra/blob/master/lib/cassandra/columns.rb

def column_family_property(column_family, key)
      cfdef = schema.cf_defs.find {|cfdef| cfdef.name == column_family }
      unless cfdef
        raise AccessError, "Invalid column family \"#{column_family}\""
      end
      cfdef.send(key)
    end

谁能指出我在这里做错了什么..

【问题讨论】:

    标签: ruby cassandra cql


    【解决方案1】:

    该客户端尚未更新为支持 CQL3。我不知道支持 CQL3 的 Ruby 客户端,所以最好的办法可能是创建一个 Thrift 兼容表(TLDR 将 WITH COMPACT STORAGE 添加到表定义中)。

    【讨论】:

    • 在创建表时添加紧凑存储解决了该问题。我昨晚在 cassandra irc 找到了解决方案.. 谢谢回答这个问题..
    • 刚刚推出 github.com/hsgubert/cassandra_migrations 以将 Rails 与 CQL3 和迁移集成以管理 cassandra 架构
    猜你喜欢
    • 1970-01-01
    • 2015-04-30
    • 2017-03-31
    • 2013-04-11
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多