Search code examples
phpcassandraphpcassapycassa

batch_mutate for counters


Is it possible to use batch_mutate for counters in php? From what I've seen, it should be possible to increment counters in general, but I can't seem to find any working examples in any language.

Thanks


Solution

  • The Mutation objects supplied to batch_mutate contain a ColumnOrSuperColumn (CoSC) object. CoSC, despite it's name, can also be a CounterColumn or SuperCounterColumn as well as Column and SuperColumn.

    Not quite sure how the PHP implementation works, but try constructing a ColumnOrSUperCOlumn as a CounterColumn and that should do what you want.

    FWIW, here is an example in Java: https://github.com/rantav/hector/blob/master/core/src/test/java/me/prettyprint/cassandra/service/BatchMutationTest.java#L135-151