def commit(self): """Makes a ``MutateRow`` API request. If no mutations have been created in the row, no request is made. Mutations are applied atomically and in order, meaning that earlier mutations can be masked / negated by later ones. Cells already present in the row are left unchanged unless explicitly changed by a mutation. After committing the accumulated mutations, resets the local mutations to an empty list. :raises: :class:`ValueError <exceptions.ValueError>` if the number of mutations exceeds the :data:`MAX_MUTATIONS`. """ mutations_list = self._get_mutations(None) num_mutations = len(mutations_list) if num_mutations == 0: return if num_mutations > MAX_MUTATIONS: raise ValueError('%d total mutations exceed the maximum allowable ' '%d.' % (num_mutations, MAX_MUTATIONS)) request_pb = messages_v2_pb2.MutateRowRequest( table_name=self._table.name, row_key=self._row_key, mutations=mutations_list, ) commit = functools.partial( self._table._instance._client._data_stub.MutateRow, request_pb) retry_ = retry.Retry(predicate=_retry_commit_exception, deadline=30) retry_(commit)() self.clear()
def _MutateRowRequestPB(*args, **kw): from google.cloud.bigtable._generated import (bigtable_pb2 as messages_v2_pb2) return messages_v2_pb2.MutateRowRequest(*args, **kw)