@@ -123,6 +123,36 @@ def _get_mutations(self, state=None):
123
123
else :
124
124
return self ._false_pb_mutations
125
125
126
+ def increment_cell_value (self , column_family_id , column , int_value ):
127
+ """Increments a value in an existing cell.
128
+ Assumes the value in the cell is stored as a 64 bit integer
129
+ serialized to bytes.
130
+ .. note::
131
+ This method adds a read-modify rule protobuf to the accumulated
132
+ read-modify rules on this :class:`Row`, but does not make an API
133
+ request. To actually send an API request (with the rules) to the
134
+ Google Cloud Bigtable API, call :meth:`commit_modifications`.
135
+ :type column_family_id: str
136
+ :param column_family_id: The column family that contains the column.
137
+ Must be of the form
138
+ ``[_a-zA-Z0-9][-_.a-zA-Z0-9]*``.
139
+ :type column: bytes
140
+ :param column: The column within the column family where the cell
141
+ is located.
142
+ :type int_value: int
143
+ :param int_value: The value to increment the existing value in the cell
144
+ by. If the targeted cell is unset, it will be treated
145
+ as containing a zero. Otherwise, the targeted cell
146
+ must contain an 8-byte value (interpreted as a 64-bit
147
+ big-endian signed integer), or the entire request
148
+ will fail.
149
+ """
150
+ column = _to_bytes (column )
151
+ rule_pb = data_pb2 .ReadModifyWriteRule (family_name = column_family_id ,
152
+ column_qualifier = column ,
153
+ increment_amount = int_value )
154
+ self ._rule_pb_list .append (rule_pb )
155
+
126
156
127
157
class RowFilter (object ):
128
158
"""Basic filter to apply to cells in a row.
0 commit comments