(Quick Reference)
Incrementing Counter Columns
Single Column
def rowKey = "xxx-1"
astyanaxService.keyspace().prepareColumnMutation("Counter1", "xxx-1", "ColumnName1")
.incrementCounterColumn(1)
.execute();
Multiple Columns
def rowKey = "xxx-1"
def m = astyanaxService.keyspace().prepareMutationBatch()
m.withRow("Counter1", rowKey)
.incrementCounterColumn("ColumnName2", 1)
.incrementCounterColumn("ColumnName3", 1)
m.execute();
Omitting Increment (defaults to 1)
def rowKey = "xxx-1"
def m = astyanaxService.keyspace().prepareMutationBatch()
m.withRow("Counter1", rowKey)
.incrementCounterColumn("ColumnName2")
.incrementCounterColumn("ColumnName3")
m.execute();
Map Argument
def rowKey = "xxx-1"
def m = m = astyanaxService.keyspace().prepareMutationBatch()
m.withRow("Counter1", rowKey)
.incrementCounterColumns(ColumnName2: 1, ColumnName3: 10, ColumnName4: 100)
m.execute();