Esempio n. 1
0
    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,
        )
        # We expect a `google.protobuf.empty_pb2.Empty`
        client = self._table._instance._client
        client._data_stub.MutateRow(request_pb)
        self.clear()
Esempio n. 2
0
def _MutateRowRequestPB(*args, **kw):
    from gcloud.bigtable._generated import (bigtable_pb2 as messages_v2_pb2)
    return messages_v2_pb2.MutateRowRequest(*args, **kw)