counter
data type is a special kind of column whose user-visible value is a 64-bit signed integer used to store a number that incrementally counts the occurrences of a particular event. Counter column tables must use counter
data type. Counters can be stored in dedicated tables only, and you cannot create an index on a counter column.INSERT
statements are not allowed on counter tables and so we must use an UPDATE
statement to update the counter column- Don't assign the
counter
data type to a column that serves as the primary key - Don't use the
counter
data type in a table that contains anything other thancounter
data types and primary keys - Don't use the
counter
data type to generate sequential numbers for surrogate keys; use thetimeuuid
data type instead
create counter_table {
rowkey ascii,
counterfield counter,
primary key (rowkey)
};
update counter_table set counterfield = counterfield + 1
where rowkey = '1';
Reference:
http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-1-a-better-implementation-of-counters
rowkey ascii,
counterfield counter,
primary key (rowkey)
};
update counter_table set counterfield = counterfield + 1
where rowkey = '1';
Reference:
http://www.datastax.com/dev/blog/whats-new-in-cassandra-2-1-a-better-implementation-of-counters
No comments:
Post a Comment