Skip to content

feat(bigtable): route single-entry MutateRows through a point-write c… - #14028

Merged
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:add-maybe-point-write-callable
Aug 11, 2026
Merged

feat(bigtable): route single-entry MutateRows through a point-write c…#14028
mutianf merged 2 commits into
googleapis:mainfrom
mutianf:add-maybe-point-write-callable

Conversation

@mutianf

@mutianf mutianf commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

…allable

Add MaybePointWriteCallable, mirroring MaybePointReadCallable: a BulkMutation with exactly one entry is converted to a RowMutation and dispatched through a point-write callable so it can benefit from the session-shim diversion, while multi-entry bulk mutations continue through the classic MutateRows path.

The point-write callable falls back to the MutateRow RPC when the session diversion does not apply, but carries the caller's bulkMutateRowsSettings retry settings/codes so a single-entry bulk write retries the same way it would have as a MutateRows call.

…allable

Add MaybePointWriteCallable, mirroring MaybePointReadCallable: a
BulkMutation with exactly one entry is converted to a RowMutation and
dispatched through a point-write callable so it can benefit from the
session-shim diversion, while multi-entry bulk mutations continue
through the classic MutateRows path.

The point-write callable falls back to the MutateRow RPC when the
session diversion does not apply, but carries the caller's
bulkMutateRowsSettings retry settings/codes so a single-entry bulk
write retries the same way it would have as a MutateRows call.
@mutianf
mutianf requested review from a team as code owners August 10, 2026 17:53

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces MaybePointWriteCallable to route single-entry BulkMutations through a unary point-write callable (MutateRow RPC) instead of the classic bulk mutation path, allowing them to benefit from session-shim diversion. It also updates EnhancedBigtableStub to integrate this new callable and adds corresponding unit tests. The review feedback suggests adding a test case to verify that a BulkMutation with zero entries is correctly routed to the classic bulk mutation path.

Comment on lines +66 to +77
@Test
public void multipleEntries_fallsThroughToClassic() {
BulkMutation request =
BulkMutation.create(TABLE_ID)
.add("row-a", Mutation.create().deleteRow())
.add("row-b", Mutation.create().deleteRow());

callable.futureCall(request, null);

assertThat(pointWriter.request).isNull();
assertThat(classic.request).isEqualTo(request);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add a test case to verify that a BulkMutation with zero entries is correctly routed to the classic bulk mutation path instead of the point-write path.

  @Test
  public void multipleEntries_fallsThroughToClassic() {
    BulkMutation request =
        BulkMutation.create(TABLE_ID)
            .add("row-a", Mutation.create().deleteRow())
            .add("row-b", Mutation.create().deleteRow());

    callable.futureCall(request, null);

    assertThat(pointWriter.request).isNull();
    assertThat(classic.request).isEqualTo(request);
  }

  @Test
  public void zeroEntries_fallsThroughToClassic() {
    BulkMutation request = BulkMutation.create(TABLE_ID);

    callable.futureCall(request, null);

    assertThat(pointWriter.request).isNull();
    assertThat(classic.request).isEqualTo(request);
  }

The point-write callable used by MaybePointWriteCallable previously fell
back to the MutateRow RPC when the session shim did not divert traffic.
Unlike point reads (where the single-row read is just ReadRows with a
limit), MutateRow and MutateRows are distinct RPCs, so this changed the
wire behavior for single-entry bulk mutations and broke tests that only
implement MutateRows.

Build the fallback classic so it delegates to the bulk MutateRows
callable as a single-entry batch, then let the shim decorate it. When
the shim diverts, the mutation goes to the session single-row write API;
otherwise it stays on MutateRows with the bulk operation's retry
behavior. This removes the need for the nullable/reference-equality
check on the shim's return value.
@mutianf
mutianf merged commit a403703 into googleapis:main Aug 11, 2026
207 of 209 checks passed
@mutianf
mutianf deleted the add-maybe-point-write-callable branch August 11, 2026 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants