ruby on rails - Cassandra cql comparator type counter -
ruby on rails - Cassandra cql comparator type counter -
i want utilize next code updating field...
@@db.execute("update user_count set counters = counters + #{val} cid = 1 ")
first time tried got next fail: cassandracql::error::invalidrequestexception: invalid operation non commutative columnfamily user_count found out have utilize comparator counter, cant find how can setup cassandra-cql gem... know how can work? below there code not work ...
@@db.execute("create columnfamily user_count(cid varchar primary key, counters counter) comparator = counter " ) @@db.execute("insert user_count (cid, counters) values (?,?)", 1, 0)
you need set default_validation=countercolumntype instead of comparator.
@@db.execute("create columnfamily user_count(cid varchar primary key, counters counter) default_validation=countercolumntype") @@db.execute("update user_count set counters = counters + 1 cid = 1")
you must utilize 'update' alter counter value, there no insert syntax counters (in cql update , insert same thing can create new rows using update).
currently cannot have counters , non-counters in same column family (from wiki: "a column family either contains counters, or no counters @ all.")
ruby-on-rails cassandra cql
Comments
Post a Comment