Dear Wiki user, You have subscribed to a wiki page or wiki category on "Cassandra Wiki" for change notification.
The "Counters" page has been changed by SylvainLebresne. http://wiki.apache.org/cassandra/Counters?action=diff&rev1=10&rev2=11 -------------------------------------------------- And read it back {{{ - rv = client.get_counter('key1', ColumnPath(column_family='Counter1', column='c1'), ConsistencyLevel.ONE) + rv = client.get('key1', ColumnPath(column_family='Counter1', column='c1'), ConsistencyLevel.ONE).counter_column.value }}} Please read the rest of this wiki page, especially Technical limitations and Operational considerations to make sure this actually does what you need. @@ -39, +39 @@ == Interface == The interface follows the main API. The main differences are: - * CounterColumn requires an i64 value (can be negative) and no timestamp, and + * CounterColumn requires an i64 value (can be negative) and no timestamp, + * Counter can be used inside super columns using the CounterSuperColumn structure, and * Deletion, when used on a counter column family, does not use a timestamp. Internally, the data store generates timestamps on the server to determine priority of deletion. @@ -55, +56 @@ 2: required list<CounterColumn> columns } - struct Counter { + struct ColumnOrSuperColumn { - 1: optional CounterColumn column, + 1: optional Column column, - 2: optional CounterSuperColumn super_column + 2: optional SuperColumn super_column, + 3: optional CounterColumn counter_column, + 4: optional CounterSuperColumn counter_super_column } }}} + where the pre-existing ColumnOrSuperColumn has the two new fields, specific to counters, `counter_column` and `counter_super_column`. - Moreover, as mentioned previously, then timestamp field of Deletion is now optional (but - remain mandatory for non counter column family operation). - The Mutation has also been updated with a new `counter` field for batch increment/decrement. + Moreover, as mentioned previously, the timestamp field of Deletion is now optional (but remain mandatory for non counter column family operation). - The counter operation comprise `batch_mutate` and the following new operations: + The counter operations comprise the usual `batch_mutate`, `get`, `get_slice`, `multiget_slice`, `multiget_count` and `get_range_slice` (secondary indexes on counter column family is not supported at the moment), as well as the following new operations for access to a single counter: {{{ # counter methods @@ -79, +81 @@ throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), /** - * Return the counter at the specified column path. - */ - Counter get_counter(1:required binary key, - 2:required ColumnPath path, - 3:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) - throws (1:InvalidRequestException ire, 2:NotFoundException nfe, 3:UnavailableException ue, 4:TimedOutException te), - - /** - * Get a list of counters from the specified columns. - */ - list<Counter> get_counter_slice(1:required binary key, - 2:required ColumnParent column_parent, - 3:required SlicePredicate predicate, - 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) - throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), - - /** - * Get counter slices from multiple keys. - */ - map<binary,list<Counter>> multiget_counter_slice(1:required list<binary> keys, - 2:required ColumnParent column_parent, - 3:required SlicePredicate predicate, - 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) - throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), - - /** * Remove a counter at the specified location. */ void remove_counter(1:required binary key, @@ -115, +91 @@ == Technical limitations == - * If a write fails unexpectedly (timeout or loss of connection to the coordinator node) the client will not know if the operation has been performed. A retry can result in an over count. + * If a write fails unexpectedly (timeout or loss of connection to the coordinator node) the client will not know if the operation has been performed. A retry can result in an over count [[https://issues.apache.org/jira/browse/CASSANDRA-2495|CASSANDRA-2495]]. - * Range slices on counter column family is not yet supported (https://issues.apache.org/jira/browse/CASSANDRA-2342). == Further reading == See [[https://issues.apache.org/jira/browse/CASSANDRA-1072|CASSANDRA-1072]] and especially the [[https://issues.apache.org/jira/secure/attachment/12459754/Partitionedcountersdesigndoc.pdf|design doc]] for further information about how this works internally.