问题
I have created a column family by following command using cqlsh:
create table mystats (key PRIMARY KEY, count counter);
Now from the cqlsh I am able to increase the counter column but when I attempt to do this from cassandra gem, as adviced at: Are there any Ruby clients for Cassandra with counters and supercolumn?
So when I use:
@stats.add(:mystats, 'randomkey', 1, 'count')
I get an error:
Cassandra::AccessError at /client Invalid column family "mystats"
When I further looked into it, I found that the error is raised from the gem: in file: 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
Can anyone please point out what I might be doing wrong here..
回答1:
That client has not yet been updated to support CQL3. I'm not aware of a CQL3-aware Ruby client, so your best bet is probably to create a Thrift-compatible table (TLDR add WITH COMPACT STORAGE
to your table definition).
来源:https://stackoverflow.com/questions/16396542/unable-to-use-cassandra-counter-column-with-cassandra-gem