Skip to content

Commit 8e1634b

Browse files
authored
feat: Reworked MutateRows to use the data client (#1290)
**Changes Made:** - Rerouted MutateRows to use the data client's `Table.bulk_mutate_rows` function. - Reworked error handling in `Table.mutate_rows`. Since we must return a list of `Status` objects, we process the list of errors obtained from the `_MutateRowsOperation` back into a corresponding list of error statuses. - Reworked retries in `Table.mutate_rows` as follows: - `retry.deadline` -> `operation_timeout` - `timeout`/`mutation_timeout` -> `attempt_timeout` - A null retry deadline now defaults to the table default mutate rows operation timeout instead of being defined as no timeout. The docstring has been updated to reflect that. A retry deadline of 0.0 will still be a no-retry option, and is implemented by setting the list of retriable errors to the empty list, and the operation timeout to the default mutate rows operation timeout. - A `timestamp` of `None` in `set_cell`, which is the default, will now generate a client-side timestamp representing the current time, rather than defaulting to using the server-side timestamp. The docstrings for this have been updated to reflect this.
1 parent 6153a5c commit 8e1634b

File tree

6 files changed

+301
-922
lines changed

6 files changed

+301
-922
lines changed

google/cloud/bigtable/data/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ def __repr__(self):
141141
return f"{self.__class__.__name__}({message!r}, {self.exceptions!r})"
142142

143143

144+
# TODO: When working on mutations batcher, rework exception handling to guarantee that
145+
# MutationsExceptionGroup only stores FailedMutationEntryErrors.
144146
class MutationsExceptionGroup(_BigtableExceptionGroup):
145147
"""
146148
Represents one or more exceptions that occur during a bulk mutation operation

google/cloud/bigtable/row.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,17 @@ def _set_cell(self, column_family_id, column, value, timestamp=None, state=None)
153153
integer (8 bytes).
154154
155155
:type timestamp: :class:`datetime.datetime`
156-
:param timestamp: (Optional) The timestamp of the operation.
156+
:param timestamp: (Optional) The timestamp of the operation. If a
157+
timestamp is not provided, the current system time
158+
will be used.
157159
158160
:type state: bool
159161
:param state: (Optional) The state that is passed along to
160162
:meth:`_get_mutations`.
161163
"""
162-
if timestamp is None:
163-
# Use current Bigtable server time.
164-
timestamp_micros = mutations._SERVER_SIDE_TIMESTAMP
164+
if timestamp is None or timestamp == mutations._SERVER_SIDE_TIMESTAMP:
165+
# Preserve special-case values (client side timestamp generation or server side timestamp)
166+
timestamp_micros = timestamp
165167
else:
166168
timestamp_micros = _microseconds_from_datetime(timestamp)
167169
# Truncate to millisecond granularity.
@@ -351,7 +353,9 @@ def set_cell(self, column_family_id, column, value, timestamp=None):
351353
integer (8 bytes).
352354
353355
:type timestamp: :class:`datetime.datetime`
354-
:param timestamp: (Optional) The timestamp of the operation.
356+
:param timestamp: (Optional) The timestamp of the operation. If a
357+
timestamp is not provided, the current system time
358+
will be used.
355359
"""
356360
self._set_cell(column_family_id, column, value, timestamp=timestamp, state=None)
357361

@@ -651,7 +655,9 @@ def set_cell(self, column_family_id, column, value, timestamp=None, state=True):
651655
integer (8 bytes).
652656
653657
:type timestamp: :class:`datetime.datetime`
654-
:param timestamp: (Optional) The timestamp of the operation.
658+
:param timestamp: (Optional) The timestamp of the operation. If a
659+
timestamp is not provided, the current system time
660+
will be used.
655661
656662
:type state: bool
657663
:param state: (Optional) The state that the mutation should be

0 commit comments

Comments
 (0)