Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private <RowT> UnaryCallable<Query, RowT> createPointReadCallable(
ServerStreamingCallable<Query, RowT> readRowCallable =
new TransformingServerStreamingCallable<>(
readRowsCallable,
(query) -> query.limit(1).toProto(requestContext),
(query) -> query.toProto(requestContext).toBuilder().setRowsLimit(1).build(),
Functions.identity());

BigtableUnaryOperationCallable<Query, RowT> classic =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ public void testCreateReadRowsCallable() throws InterruptedException {
Query request = Query.create(TableId.of("table-id")).rowKey("row-key");
streamingCallable.call(request).iterator().next();
ReadRowsRequest expected =
request.toProto(RequestContext.create(PROJECT_ID, INSTANCE_ID, APP_PROFILE_ID));
request.toProto(RequestContext.create(PROJECT_ID, INSTANCE_ID, APP_PROFILE_ID)).toBuilder()
.setRowsLimit(1)
.build();
assertThat(fakeDataService.popLastRequest()).isEqualTo(expected);
}

Expand Down Expand Up @@ -981,6 +983,19 @@ public void testExecuteQueryWaitTimeoutWorksWithMetadataFuture() throws IOExcept
}
}

@Test
public void testReadRowDoesNotMutateQuery() throws Exception {
Query query = Query.create(TABLE_ID).rowKey("row-key");
enhancedBigtableStub.readRowCallable().call(query);
assertThat(fakeDataService.popLastRequest().getRowsLimit()).isEqualTo(1L);
assertThat(query).isEqualTo(Query.create(TABLE_ID).rowKey("row-key"));

// Reusing the query for a multi-row scan should not inherit rows_limit = 1
query.rowKey("row-key-2");
enhancedBigtableStub.readRowsCallable().all().call(query);
assertThat(fakeDataService.popLastRequest().getRowsLimit()).isEqualTo(0L);
}

private static class MetadataInterceptor implements ServerInterceptor {
final BlockingQueue<Metadata> headers = Queues.newLinkedBlockingDeque();

Expand Down
Loading