You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by Apache Wiki <wi...@apache.org> on 2010/12/22 00:16:28 UTC
[Cassandra Wiki] Update of "Counters" by johanoskarsson
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 johanoskarsson.
http://wiki.apache.org/cassandra/Counters?action=diff&rev1=2&rev2=3
--------------------------------------------------
= Counters in Cassandra =
== Getting started ==
+
+ In order to use counters in Cassandra you need to first set up a cluster, see the [[http://wiki.apache.org/cassandra/GettingStarted|Getting started]] guide for more information. Currently the counters code is slated for a release in Cassandra 0.8.0.
+
+ ==== Configuration ====
+
+ When first setting up the cluster you can specify a column or super column that will act as counters.
+ For example using the cassandra.yaml configuration file:
+
+ {{{
+ - name: Counter1
+ default_validation_class: CounterColumnType
+
+ - name: SuperCounter1
+ column_type: Super
+ default_validation_class: CounterColumnType
+ }}}
+
+ ==== Incrementing and accessing counters ====
+
+ Once the cluster is up and running with these settings you can simply increment or decrement long values from the counters as follows (example is using the python thrift client):
+
+ {{{
+ client.add('key1', ColumnParent(column_family='Counter1'), CounterColumn('c1', 100), ConsistencyLevel.ONE)
+ client.add('key1', ColumnParent(column_family='Counter1'), CounterColumn('c1', -50), ConsistencyLevel.ONE)
+ }}}
+
+ And read it back
+ {{{
+ rv = client.get_counter('key1', ColumnPath(column_family='Counter1', column='c1'), ConsistencyLevel.ONE)
+ }}}
+
+ Please read the rest of this wiki page, especially Technical limitations and Operational considerations to make sure this actually does what you need.
+
== Interface ==
== Technical limitations ==
== Operational considerations ==
== 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.