Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mutate rows batching #770

Merged
merged 159 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
1d02154
added initial implementation of mutate_rows
daniel-sanche Apr 24, 2023
ab63cba
implemented mutation models
daniel-sanche Apr 24, 2023
cf9daa5
added retries to mutate_row
daniel-sanche Apr 24, 2023
1247da4
return exception group if possible
daniel-sanche Apr 24, 2023
3b3ed8c
check for idempotence
daniel-sanche Apr 24, 2023
5d20037
initial implementation for bulk_mutations
daniel-sanche Apr 24, 2023
3d322a1
include successes in bulk mutation error message
daniel-sanche Apr 24, 2023
a31232b
fixed style checks
daniel-sanche Apr 24, 2023
8da2d65
added basic system tests
daniel-sanche Apr 24, 2023
2b89d9c
added unit tests for mutate_row
daniel-sanche Apr 25, 2023
47c5985
ran blacken
daniel-sanche Apr 25, 2023
38fdcd7
improved exceptions
daniel-sanche Apr 25, 2023
504d2d8
added bulk_mutate_rows unit tests
daniel-sanche Apr 25, 2023
b16067f
ran blacken
daniel-sanche Apr 25, 2023
3ab1405
support __new___ for exceptions for python3.11+
daniel-sanche Apr 25, 2023
0a6c0c6
added exception unit tests
daniel-sanche Apr 25, 2023
ec043cf
makde exceptions tuple
daniel-sanche Apr 26, 2023
518530e
got exceptions to print consistently across versions
daniel-sanche Apr 26, 2023
9624729
added test for 311 rich traceback
daniel-sanche Apr 27, 2023
3087081
moved retryable row mutations to new file
daniel-sanche Apr 27, 2023
9df588f
use index map
daniel-sanche Apr 27, 2023
7ed8be3
added docstring
daniel-sanche Apr 27, 2023
2536cc4
added predicate check to failed mutations
daniel-sanche Apr 27, 2023
1f6875c
added _mutate_rows tests
daniel-sanche Apr 27, 2023
1ea24e6
improved client tests
daniel-sanche Apr 27, 2023
25ca2d2
refactored to loop by raising exception
daniel-sanche Apr 28, 2023
c0787db
refactored retry deadline logic into shared wrapper
daniel-sanche Apr 28, 2023
3ed5c3d
ran black
daniel-sanche Apr 28, 2023
a91fbcb
pulled in table default timeouts
daniel-sanche Apr 28, 2023
df8a058
added tests for shared deadline parsing function
daniel-sanche Apr 28, 2023
b866b57
added tests for mutation models
daniel-sanche Apr 28, 2023
54a4d43
fixed linter errors
daniel-sanche Apr 28, 2023
bd51dc4
added tests for BulkMutationsEntry
daniel-sanche Apr 28, 2023
921b05a
improved mutations documentation
daniel-sanche Apr 28, 2023
53f7ad2
added basic implementation for batcher
daniel-sanche May 1, 2023
f65b2e5
added flush timer
daniel-sanche May 1, 2023
7051cd2
added flush on size and count
daniel-sanche May 1, 2023
9731f4c
improved queue
daniel-sanche May 1, 2023
34bf655
raise exceptions on close
daniel-sanche May 1, 2023
582457a
added args for flush
daniel-sanche May 1, 2023
eeb24a5
improved closing logic
daniel-sanche May 1, 2023
110cd96
use custom queue type to track size and count
daniel-sanche May 1, 2023
375a77d
added flow control
daniel-sanche May 1, 2023
5f9fa3f
added comments and todos
daniel-sanche May 1, 2023
e63cfc2
allow None for batcher limits
daniel-sanche May 2, 2023
d5e15aa
strip indices from exceptions
daniel-sanche May 2, 2023
82ea61f
refactored mutate_rows logic into helper function
daniel-sanche May 2, 2023
fa42b86
implemented callbacks for mutate_rows
daniel-sanche May 2, 2023
a47aeda
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 2, 2023
ee23721
release locks as mutations are completed, instead of waiting until end
daniel-sanche May 2, 2023
b69cc96
refacotr row processing
daniel-sanche May 2, 2023
9e1850c
FlowControl returns exceptions rather than raises them
daniel-sanche May 2, 2023
9e4d013
raise previous exceptions on flush with flag set
daniel-sanche May 2, 2023
2c7ec9c
disallow empty bulk mutation entries
daniel-sanche May 3, 2023
5c4f739
simplified staged mutation store
daniel-sanche May 3, 2023
fa4947f
ran blacken
daniel-sanche May 3, 2023
914b24b
replaced semaphores with condition
daniel-sanche May 3, 2023
8bda651
fixed mypy issues
daniel-sanche May 3, 2023
742194b
added raise_exceptions fn
daniel-sanche May 3, 2023
45fe1f5
fixed failing tests
daniel-sanche May 3, 2023
d8f3a4d
added skeleton for tests
daniel-sanche May 3, 2023
7faebc0
improved and tested flow control
daniel-sanche May 4, 2023
10da89a
refactored flushes to run sequentially
daniel-sanche May 5, 2023
0eca65e
added batcher tests
daniel-sanche May 5, 2023
2532b63
ran blacken
daniel-sanche May 5, 2023
8313b57
added additional tests
daniel-sanche May 5, 2023
01a16f3
made exceptions into a tuple
daniel-sanche May 5, 2023
da9b6cf
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 5, 2023
b7d3fcf
added warning for unflushed mutation entries
daniel-sanche May 5, 2023
6140acb
remove aborted from retryable errors
daniel-sanche May 22, 2023
36ba2b6
improved SetCell mutation
daniel-sanche May 22, 2023
b3c9017
fixed mutations tests
daniel-sanche May 22, 2023
cac9e2d
SetCell timestamps use millisecond precision
daniel-sanche May 22, 2023
34b051f
renamed BulkMutationsEntry to RowMutationEntry
daniel-sanche May 22, 2023
63ac35c
Merge branch 'v3' into mutate_rows
daniel-sanche May 24, 2023
bb72ea8
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 24, 2023
a51201c
added metadata to mutate rows and bulk mutate rows
daniel-sanche May 25, 2023
a21bebf
moved _convert_retry_deadline wrapper from exceptions into _helpers
daniel-sanche May 25, 2023
4ca89d9
fixed system tests
daniel-sanche May 25, 2023
b240ee1
only handle precision adjustment when creating timestamp
daniel-sanche May 26, 2023
cb0e951
added _from_dict for mutation models
daniel-sanche May 26, 2023
a9cf385
rpc timeouts adjust when approaching operation_timeout
daniel-sanche May 26, 2023
eddc1c9
pass table instead of request dict
daniel-sanche May 26, 2023
f8b26aa
refactoring mutate rows
daniel-sanche May 27, 2023
5b80dc5
made on_terminal_state into coroutine
daniel-sanche May 27, 2023
9e5b80a
fixed style issues
daniel-sanche May 27, 2023
f7539f6
moved callback rewriting into retryable attempt
daniel-sanche May 27, 2023
e77a4fa
fixed tests
daniel-sanche May 27, 2023
4e19ed0
pop successful mutations from error dict
daniel-sanche May 30, 2023
920e4b7
removed unneeded check
daniel-sanche May 30, 2023
725f5ff
refactoring
daniel-sanche May 30, 2023
1054bc4
pass list of exceptions in callback
daniel-sanche May 30, 2023
f39a891
raise error in unexpected state
daniel-sanche May 30, 2023
e5f65f2
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche May 31, 2023
8038662
added timeout to user facing flush
daniel-sanche May 31, 2023
c2ec26d
added comments
daniel-sanche May 31, 2023
1d97135
removed callback
daniel-sanche May 31, 2023
88e2bf5
refactoring mutation attempt into class
daniel-sanche May 31, 2023
a3c0166
use partial function
daniel-sanche May 31, 2023
70c35ef
renamed class
daniel-sanche May 31, 2023
e00f592
added comments
daniel-sanche Jun 1, 2023
18af78a
added tests
daniel-sanche Jun 1, 2023
23e84f5
improved helpers
daniel-sanche Jun 1, 2023
56fdf7c
refactored operation into class only
daniel-sanche Jun 5, 2023
aca31f0
restructured how remaining indices are tracked
daniel-sanche Jun 5, 2023
5a5d541
fixed tests
daniel-sanche Jun 5, 2023
afed731
added docstrings
daniel-sanche Jun 5, 2023
2396ec8
moved index deletion to end of block
daniel-sanche Jun 6, 2023
3d441a2
added comment to exception types
daniel-sanche Jun 6, 2023
0013c4d
Merge branch 'mutate_rows' into mutate_rows_batch
daniel-sanche Jun 6, 2023
8b41518
update flow control after batch, instead of after each entry
daniel-sanche Jun 6, 2023
5a8b9e9
Merge branch 'v3' into mutate_rows_batch
daniel-sanche Jun 6, 2023
bdd7f45
fixed test
daniel-sanche Jun 6, 2023
553bc4a
add kwargs docstring
daniel-sanche Jun 7, 2023
20156c6
allow mutations over flow limits
daniel-sanche Jun 7, 2023
b9c4467
added limits for mutate_rows mutation and entry counts
daniel-sanche Jun 7, 2023
8b8d8ab
refactored mutation system tests
daniel-sanche Jun 7, 2023
a1de714
added batcher system tests
daniel-sanche Jun 7, 2023
2382a04
allow batcher to append multiple entries
daniel-sanche Jun 7, 2023
1db0377
improved timeout handling
daniel-sanche Jun 7, 2023
6a66c48
made batch rpcs concurrent
daniel-sanche Jun 14, 2023
e1718f0
allow single mutations in flow control public methods
daniel-sanche Jun 14, 2023
eeda2e9
mutation batcher only accepts single entries
daniel-sanche Jun 15, 2023
eeb483f
ensure that proper exceptions are raised for each flush
daniel-sanche Jun 15, 2023
853b5f2
surface unexpected exceptions in MutationsExceptionGroup
daniel-sanche Jun 15, 2023
2865acd
prefixed flow control attributes with underscore
daniel-sanche Jun 15, 2023
e568d92
batcher signature improvements
daniel-sanche Jun 15, 2023
bc7b850
use request mutation limit instead of entry limit
daniel-sanche Jun 15, 2023
ff0aed6
reduce repeated flush tasks when entries appended in a loop
daniel-sanche Jun 15, 2023
f71eebc
renamed variables
daniel-sanche Jun 15, 2023
c0dc760
added test; renamed variables
daniel-sanche Jun 15, 2023
a6b12dc
removed outdated comment
daniel-sanche Jun 16, 2023
d5128eb
added comments
daniel-sanche Jun 16, 2023
335391c
renamed variable
daniel-sanche Jun 16, 2023
836171b
made append async; removed _pending_entries
daniel-sanche Jun 20, 2023
06f16bc
use futures instead of tasks for type hints
daniel-sanche Jun 20, 2023
09a5d51
refactored asyncio calls out to make sync implementation easier
daniel-sanche Jun 20, 2023
0b0f30e
renamed flow_control_max_count
daniel-sanche Jun 21, 2023
283a949
removed None as a flow_control_max_* option
daniel-sanche Jun 21, 2023
834db1a
fixed type annotation
daniel-sanche Jun 21, 2023
524f2d8
fixed tests
daniel-sanche Jun 21, 2023
df8d2d5
improved docstrings
daniel-sanche Jun 21, 2023
eaed9ab
added timeouts to batcher init
daniel-sanche Jun 21, 2023
e0b5e27
fixed 3.11 test issue
daniel-sanche Jun 22, 2023
d50d89b
fixed 3.7 unit test issues
daniel-sanche Jun 22, 2023
32d39fd
fixed lint issue
daniel-sanche Jun 22, 2023
1343b34
fixed lint
daniel-sanche Jun 22, 2023
12099f5
remove index from exceptions
daniel-sanche Jun 23, 2023
6833707
added test for memory leaks
daniel-sanche Jun 23, 2023
4c40299
clear task after completion
daniel-sanche Jun 23, 2023
2931aa8
added exception list truncation
daniel-sanche Jun 23, 2023
1dc760e
removed index information
daniel-sanche Jun 23, 2023
badbb83
fixed existing tests
daniel-sanche Jun 23, 2023
97e6680
Merge branch 'v3' into mutate_rows_batch
daniel-sanche Jun 23, 2023
6da9a64
removed manual flushing
daniel-sanche Jun 23, 2023
0ecbbcd
added tests
daniel-sanche Jun 23, 2023
61b367a
pr comment improvements
daniel-sanche Jun 23, 2023
c66260e
added todo; removed stale comment
daniel-sanche Jun 26, 2023
ddacd18
Merge branch 'v3' into mutate_rows_batch
daniel-sanche Jun 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion google/cloud/bigtable/_mutate_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from google.cloud.bigtable.client import Table
from google.cloud.bigtable.mutations import RowMutationEntry

# mutate_rows requests are limited to this value
MUTATE_ROWS_REQUEST_MUTATION_LIMIT = 100_000


class _MutateRowsIncomplete(RuntimeError):
"""
Expand Down Expand Up @@ -68,6 +71,14 @@ def __init__(
- per_request_timeout: the timeoutto use for each mutate_rows attempt, in seconds.
If not specified, the request will run until operation_timeout is reached.
"""
# check that mutations are within limits
total_mutations = sum(len(entry.mutations) for entry in mutation_entries)
if total_mutations > MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
raise ValueError(
"mutate_rows requests can contain at most "
f"{MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations across "
f"all entries. Found {total_mutations}."
)
# create partial function to pass to trigger rpc call
metadata = _make_metadata(table.table_name, table.app_profile_id)
self._gapic_fn = functools.partial(
Expand Down Expand Up @@ -119,7 +130,7 @@ async def start(self):
self._handle_entry_error(idx, exc)
finally:
# raise exception detailing incomplete mutations
all_errors = []
all_errors: list[Exception] = []
for idx, exc_list in self.errors.items():
if len(exc_list) == 0:
raise core_exceptions.ClientError(
Expand Down
47 changes: 35 additions & 12 deletions google/cloud/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
Any,
Optional,
Set,
Callable,
Coroutine,
TYPE_CHECKING,
)

Expand Down Expand Up @@ -60,6 +58,8 @@
from google.cloud.bigtable._mutate_rows import _MutateRowsOperation
from google.cloud.bigtable._helpers import _make_metadata
from google.cloud.bigtable._helpers import _convert_retry_deadline
from google.cloud.bigtable.mutations_batcher import MutationsBatcher
from google.cloud.bigtable.mutations_batcher import _MB_SIZE
from google.cloud.bigtable._helpers import _attempt_timeout_generator

from google.cloud.bigtable.read_modify_write_rules import ReadModifyWriteRule
Expand All @@ -69,7 +69,6 @@
from google.cloud.bigtable.row_filters import RowFilterChain

if TYPE_CHECKING:
from google.cloud.bigtable.mutations_batcher import MutationsBatcher
from google.cloud.bigtable import RowKeySamples
from google.cloud.bigtable import ShardedQuery

Expand Down Expand Up @@ -753,17 +752,48 @@ async def execute_rpc():
)
return await wrapped_fn()

def mutations_batcher(self, **kwargs) -> MutationsBatcher:
def mutations_batcher(
self,
*,
flush_interval: float | None = 5,
flush_limit_mutation_count: int | None = 1000,
flush_limit_bytes: int = 20 * _MB_SIZE,
flow_control_max_mutation_count: int = 100_000,
flow_control_max_bytes: int = 100 * _MB_SIZE,
batch_operation_timeout: float | None = None,
batch_per_request_timeout: float | None = None,
) -> MutationsBatcher:
"""
Returns a new mutations batcher instance.

Can be used to iteratively add mutations that are flushed as a group,
to avoid excess network calls

Args:
- flush_interval: Automatically flush every flush_interval seconds. If None,
a table default will be used
- flush_limit_mutation_count: Flush immediately after flush_limit_mutation_count
mutations are added across all entries. If None, this limit is ignored.
- flush_limit_bytes: Flush immediately after flush_limit_bytes bytes are added.
- flow_control_max_mutation_count: Maximum number of inflight mutations.
- flow_control_max_bytes: Maximum number of inflight bytes.
- batch_operation_timeout: timeout for each mutate_rows operation, in seconds. If None,
table default_operation_timeout will be used
- batch_per_request_timeout: timeout for each individual request, in seconds. If None,
table default_per_request_timeout will be used
Returns:
- a MutationsBatcher context manager that can batch requests
"""
return MutationsBatcher(self, **kwargs)
return MutationsBatcher(
self,
flush_interval=flush_interval,
flush_limit_mutation_count=flush_limit_mutation_count,
flush_limit_bytes=flush_limit_bytes,
flow_control_max_mutation_count=flow_control_max_mutation_count,
flow_control_max_bytes=flow_control_max_bytes,
batch_operation_timeout=batch_operation_timeout,
batch_per_request_timeout=batch_per_request_timeout,
)

async def mutate_row(
self,
Expand Down Expand Up @@ -861,10 +891,6 @@ async def bulk_mutate_rows(
*,
operation_timeout: float | None = 60,
per_request_timeout: float | None = None,
on_success: Callable[
[int, RowMutationEntry], None | Coroutine[None, None, None]
]
| None = None,
):
"""
Applies mutations for multiple rows in a single batched request.
Expand All @@ -890,9 +916,6 @@ async def bulk_mutate_rows(
in seconds. If it takes longer than this time to complete, the request
will be cancelled with a DeadlineExceeded exception, and a retry will
be attempted if within operation_timeout budget
- on_success: a callback function that will be called when each mutation
entry is confirmed to be applied successfully. Will be passed the
index and the entry itself.
Raises:
- MutationsExceptionGroup if one or more mutations fails
Contains details about any failed entries in .exceptions
Expand Down
100 changes: 90 additions & 10 deletions google/cloud/bigtable/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,96 @@ def __str__(self):
class MutationsExceptionGroup(BigtableExceptionGroup):
"""
Represents one or more exceptions that occur during a bulk mutation operation

Exceptions will typically be of type FailedMutationEntryError, but other exceptions may
be included if they are raised during the mutation operation
"""

@staticmethod
def _format_message(excs: list[FailedMutationEntryError], total_entries: int):
entry_str = "entry" if total_entries == 1 else "entries"
plural_str = "" if len(excs) == 1 else "s"
return f"{len(excs)} sub-exception{plural_str} (from {total_entries} {entry_str} attempted)"
def _format_message(
excs: list[Exception], total_entries: int, exc_count: int | None = None
) -> str:
"""
Format a message for the exception group

Args:
- excs: the exceptions in the group
- total_entries: the total number of entries attempted, successful or not
- exc_count: the number of exceptions associated with the request
if None, this will be len(excs)
"""
exc_count = exc_count if exc_count is not None else len(excs)
entry_str = "entry" if exc_count == 1 else "entries"
return f"{exc_count} failed {entry_str} from {total_entries} attempted."

def __init__(
self, excs: list[Exception], total_entries: int, message: str | None = None
):
"""
Args:
- excs: the exceptions in the group
- total_entries: the total number of entries attempted, successful or not
- message: the message for the exception group. If None, a default message
will be generated
"""
message = (
message
if message is not None
else self._format_message(excs, total_entries)
)
super().__init__(message, excs)
self.total_entries_attempted = total_entries

def __init__(self, excs: list[FailedMutationEntryError], total_entries: int):
super().__init__(self._format_message(excs, total_entries), excs)
def __new__(
cls, excs: list[Exception], total_entries: int, message: str | None = None
):
"""
Args:
- excs: the exceptions in the group
- total_entries: the total number of entries attempted, successful or not
- message: the message for the exception group. If None, a default message
"""
message = (
message if message is not None else cls._format_message(excs, total_entries)
)
instance = super().__new__(cls, message, excs)
instance.total_entries_attempted = total_entries
return instance

def __new__(cls, excs: list[FailedMutationEntryError], total_entries: int):
return super().__new__(cls, cls._format_message(excs, total_entries), excs)
@classmethod
def from_truncated_lists(
cls,
first_list: list[Exception],
last_list: list[Exception],
total_excs: int,
entry_count: int,
) -> MutationsExceptionGroup:
"""
Create a MutationsExceptionGroup from two lists of exceptions, representing
a larger set that has been truncated. The MutationsExceptionGroup will
contain the union of the two lists as sub-exceptions, and the error message
describe the number of exceptions that were truncated.

Args:
- first_list: the set of oldest exceptions to add to the ExceptionGroup
- last_list: the set of newest exceptions to add to the ExceptionGroup
- total_excs: the total number of exceptions associated with the request
Should be len(first_list) + len(last_list) + number of dropped exceptions
in the middle
- entry_count: the total number of entries attempted, successful or not
"""
first_count, last_count = len(first_list), len(last_list)
if first_count + last_count >= total_excs:
# no exceptions were dropped
return cls(first_list + last_list, entry_count)
excs = first_list + last_list
truncation_count = total_excs - (first_count + last_count)
base_message = cls._format_message(excs, entry_count, total_excs)
first_message = f"first {first_count}" if first_count else ""
last_message = f"last {last_count}" if last_count else ""
conjunction = " and " if first_message and last_message else ""
message = f"{base_message} ({first_message}{conjunction}{last_message} attached as sub-exceptions; {truncation_count} truncated)"
return cls(excs, entry_count, message)


class FailedMutationEntryError(Exception):
Expand All @@ -108,14 +185,17 @@ class FailedMutationEntryError(Exception):

def __init__(
self,
failed_idx: int,
failed_idx: int | None,
failed_mutation_entry: "RowMutationEntry",
cause: Exception,
):
idempotent_msg = (
"idempotent" if failed_mutation_entry.is_idempotent() else "non-idempotent"
)
message = f"Failed {idempotent_msg} mutation entry at index {failed_idx} with cause: {cause!r}"
index_msg = f" at index {failed_idx} " if failed_idx is not None else " "
message = (
f"Failed {idempotent_msg} mutation entry{index_msg}with cause: {cause!r}"
)
super().__init__(message)
self.index = failed_idx
self.entry = failed_mutation_entry
Expand Down
23 changes: 23 additions & 0 deletions google/cloud/bigtable/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
import time
from dataclasses import dataclass
from abc import ABC, abstractmethod
from sys import getsizeof

# mutation entries above this should be rejected
from google.cloud.bigtable._mutate_rows import MUTATE_ROWS_REQUEST_MUTATION_LIMIT


from google.cloud.bigtable.read_modify_write_rules import MAX_INCREMENT_VALUE

Expand All @@ -41,6 +46,12 @@ def is_idempotent(self) -> bool:
def __str__(self) -> str:
return str(self._to_dict())

def size(self) -> int:
"""
Get the size of the mutation in bytes
"""
return getsizeof(self._to_dict())

@classmethod
def _from_dict(cls, input_dict: dict[str, Any]) -> Mutation:
instance: Mutation | None = None
Expand Down Expand Up @@ -195,6 +206,12 @@ def __init__(self, row_key: bytes | str, mutations: Mutation | list[Mutation]):
row_key = row_key.encode("utf-8")
if isinstance(mutations, Mutation):
mutations = [mutations]
if len(mutations) == 0:
raise ValueError("mutations must not be empty")
elif len(mutations) > MUTATE_ROWS_REQUEST_MUTATION_LIMIT:
raise ValueError(
f"entries must have <= {MUTATE_ROWS_REQUEST_MUTATION_LIMIT} mutations"
)
self.row_key = row_key
self.mutations = tuple(mutations)

Expand All @@ -208,6 +225,12 @@ def is_idempotent(self) -> bool:
"""Check if the mutation is idempotent"""
return all(mutation.is_idempotent() for mutation in self.mutations)

def size(self) -> int:
"""
Get the size of the mutation in bytes
"""
return getsizeof(self._to_dict())

@classmethod
def _from_dict(cls, input_dict: dict[str, Any]) -> RowMutationEntry:
return RowMutationEntry(
Expand Down
Loading