Skip to content

Commit

Permalink
Updated the Stub to not externalize the field 'readRowRawCallable' an…
Browse files Browse the repository at this point in the history
…d to create the object inside of the primer
  • Loading branch information
diegomez17 committed Nov 30, 2021
1 parent 0bae71d commit 258b391
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Expand Up @@ -24,7 +24,9 @@
import com.google.api.gax.grpc.ChannelPrimer;
import com.google.api.gax.grpc.GrpcTransportChannel;
import com.google.api.gax.rpc.FixedTransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.auth.Credentials;
import com.google.cloud.bigtable.data.v2.models.DefaultRowAdapter;
import com.google.cloud.bigtable.data.v2.models.Query;
import com.google.cloud.bigtable.data.v2.models.Row;
import com.google.common.base.Preconditions;
Expand Down Expand Up @@ -143,8 +145,10 @@ private void sendPrimeRequests(ManagedChannel managedChannel) throws IOException

// Prime all of the table ids in parallel
for (String tableId : tableIds) {
UnaryCallable<Query, Row> callable = stub.createReadRowRawCallable(new DefaultRowAdapter());

ApiFuture<Row> f =
stub.readRowRawCallable()
callable
.futureCall(Query.create(tableId).rowKey(PRIMING_ROW_KEY).filter(FILTERS.block()));

primeFutures.put(tableId, f);
Expand Down
Expand Up @@ -132,7 +132,6 @@ public class EnhancedBigtableStub implements AutoCloseable {

private final ServerStreamingCallable<Query, Row> readRowsCallable;
private final UnaryCallable<Query, Row> readRowCallable;
private final UnaryCallable<Query, Row> readRowRawCallable;
private final UnaryCallable<String, List<KeyOffset>> sampleRowKeysCallable;
private final UnaryCallable<RowMutation, Void> mutateRowCallable;
private final UnaryCallable<BulkMutation, Void> bulkMutateRowsCallable;
Expand Down Expand Up @@ -268,7 +267,6 @@ public EnhancedBigtableStub(EnhancedBigtableStubSettings settings, ClientContext

readRowsCallable = createReadRowsCallable(new DefaultRowAdapter());
readRowCallable = createReadRowCallable(new DefaultRowAdapter());
readRowRawCallable = createReadRowRawCallable(new DefaultRowAdapter());
sampleRowKeysCallable = createSampleRowKeysCallable();
mutateRowCallable = createMutateRowCallable();
bulkMutateRowsCallable = createBulkMutateRowsCallable();
Expand Down Expand Up @@ -332,11 +330,19 @@ public <RowT> ServerStreamingCallable<Query, RowT> createReadRowsCallable(
/**
* Creates a callable chain to handle point ReadRows RPCs. The chain will:
*
*
* <ul>
* <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest} and
* dispatch the RPC.
* <li>Upon receiving the response stream, it will merge the {@link
* com.google.bigtable.v2.ReadRowsResponse.CellChunk}s in logical rows. The actual row
* implementation can be configured in by the {@code rowAdapter} parameter.
* <li>Retry/resume on failure.
* <li>Filter out marker rows.
* </ul>
*
* <p>NOTE: the caller is responsible for adding tracing & metrics.</p>
*/
public <RowT> UnaryCallable<Query, RowT> createReadRowRawCallable(RowAdapter<RowT> rowAdapter) {
protected <RowT> UnaryCallable<Query, RowT> createReadRowRawCallable(RowAdapter<RowT> rowAdapter) {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable =
createReadRowsBaseCallable(
ServerStreamingCallSettings.<ReadRowsRequest, Row>newBuilder()
Expand Down Expand Up @@ -793,10 +799,6 @@ public UnaryCallable<Query, Row> readRowCallable() {
return readRowCallable;
}

public UnaryCallable<Query, Row> readRowRawCallable() {
return readRowRawCallable;
}

public UnaryCallable<String, List<KeyOffset>> sampleRowKeysCallable() {
return sampleRowKeysCallable;
}
Expand Down

0 comments on commit 258b391

Please sign in to comment.