cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Yudovin <vla...@winguzone.com>
Subject Re: Having Counters in a Collection, like a map<int, counter>?
Date Wed, 09 Nov 2016 12:32:45 GMT
Unfortunately it's impossible nor to use counters inside collections neither mix them with
other non-counter columns :



CREATE TABLE cnt (id int PRIMARY KEY , cntmap MAP&lt;int,counter&gt;);

InvalidRequest: Error from server: code=2200 [Invalid query] message="Counters are not allowed
inside collections: map&lt;int, counter&gt;"



CREATE TABLE cnt (id int PRIMARY KEY , cnt1 counter, txt text);

InvalidRequest: Error from server: code=2200 [Invalid query] message="Cannot mix counter and
non counter columns in the same table"





&gt;Is there a way to do this in c* which doesn't require creating 1 table per type of
map&lt;int, counter&gt; that i need?

But you don't need to create separate table per each counter, just use one row per counter:



CREATE TABLE cnt (id int PRIMARY KEY , value counter);



Best regards, Vladimir Yudovin, 

Winguzone - Hosted Cloud Cassandra
Launch your cluster in minutes.





---- On Wed, 09 Nov 2016 07:17:53 -0500Ali Akhtar &lt;ali.rac200@gmail.com&gt; wrote
----




I have a use-case where I need to have a dynamic number of counters.



The easiest way to do this would be to have a map&lt;int, counter&gt; where the int
is the key, and the counter is the value which is incremented / decremented. E.g if something
related to 5 happened, then i'd get the counter for 5 and increment / decrement it.



I also need to have multiple map&lt;int, counter&gt;s of this type, where each int
is a key referring to something different.



Is there a way to do this in c* which doesn't require creating 1 table per type of map&lt;int,
counter&gt; that i need?








Mime
View raw message