Atomic counter provides real-time statistics for online applications, such as the real-time page views (PVs) of a post.

Note For more information about atomic counter, see Atomic counters.


The following operations have been added to the RowUpdateChange class to operate an atomic counter:
  • RowUpdateChange increment(Column column) is used to increment or decrement an attribute value by a number.
  • void addReturnColumn(String columnName) is used to specify the column to operate an atomic counter.
  • void setReturnType(ReturnType.RT_AFTER_MODIFY) is used to specify a flag to indicate that the updated value of the atomic counter must be returned.


The following code provides an example on how to use the RowUpdateChange operation to update the columns whose valid values are integers when writing a row of data:
private static void incrementByUpdateRowApi(SyncClient client) {
    // Specify primary keys.
    PrimaryKeyBuilder primaryKeyBuilder = PrimaryKeyBuilder.createPrimaryKeyBuilder();
    primaryKeyBuilder.addPrimaryKeyColumn(PRIMARY_KEY_NAME, PrimaryKeyValue.fromString("pk0"));
    PrimaryKey primaryKey =;
    RowUpdateChange rowUpdateChange = new RowUpdateChange(TABLE_NAME, primaryKey);
    // Specify to increment the price value by 10 without specifying a timestamp.
    rowUpdateChange.increment(new Column("price", ColumnValue.fromLong(10)));
    // Set ReturnType to obtain the updated values of the atomic counter.
    // Initiate a request to update the price attribute.
    UpdateRowResponse response = client.updateRow(new UpdateRowRequest(rowUpdateChange));
    // Display the updated values.
    Row row = response.getRow();