use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable-hbase by googleapis.
the class BulkReadVeneerApi method getOrCreateBatcher.
private Batcher<ByteString, Row> getOrCreateBatcher(@Nullable Filters.Filter filter) {
RowFilter proto = filter == null ? null : filter.toProto();
Batcher<ByteString, Row> batcher = batchers.get(proto);
if (batcher == null) {
batcher = client.newBulkReadRowsBatcher(tableId, filter, callContext);
batchers.put(proto, batcher);
}
return batcher;
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class BigtableChannelPrimer method sendPrimeRequests.
private void sendPrimeRequests(ManagedChannel managedChannel) throws IOException {
// Wrap the channel in a temporary stub
EnhancedBigtableStubSettings primingSettings = settingsTemplate.toBuilder().setTransportChannelProvider(FixedTransportChannelProvider.create(GrpcTransportChannel.create(managedChannel))).build();
try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(primingSettings)) {
Map<String, ApiFuture<?>> primeFutures = new HashMap<>();
// Prime all of the table ids in parallel
for (String tableId : tableIds) {
ApiFuture<Row> f = stub.createReadRowsRawCallable(new DefaultRowAdapter()).first().futureCall(ReadRowsRequest.newBuilder().setTableName(TableName.format(primingSettings.getProjectId(), primingSettings.getInstanceId(), tableId)).setAppProfileId(primingSettings.getAppProfileId()).setRows(RowSet.newBuilder().addRowKeys(PRIMING_ROW_KEY).build()).setFilter(RowFilter.newBuilder().setBlockAllFilter(true).build()).setRowsLimit(1).build());
primeFutures.put(tableId, f);
}
// Wait for all of the prime requests to complete.
for (Map.Entry<String, ApiFuture<?>> entry : primeFutures.entrySet()) {
try {
entry.getValue().get();
} catch (Throwable e) {
if (e instanceof ExecutionException) {
e = e.getCause();
}
LOG.warning(String.format("Failed to prime channel for table: %s: %s", entry.getKey(), e.getMessage()));
}
}
}
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createBulkReadRowsCallable.
/**
* Creates a callable chain to handle bulk ReadRows RPCs. This is meant to be used in ReadRows
* batcher. The chain will:
*
* <ul>
* <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest}.
* <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.
* <li>Construct a {@link UnaryCallable} that will buffer the entire stream into memory before
* completing. If the stream is empty, then the list will be empty.
* <li>Add tracing & metrics.
* </ul>
*/
private <RowT> UnaryCallable<Query, List<RowT>> createBulkReadRowsCallable(RowAdapter<RowT> rowAdapter) {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable = createReadRowsBaseCallable(settings.readRowsSettings(), rowAdapter);
ServerStreamingCallable<Query, RowT> readRowsUserCallable = new ReadRowsUserCallable<>(readRowsCallable, requestContext);
SpanName span = getSpanName("ReadRows");
// The TracedBatcherUnaryCallable has to be wrapped by the TracedUnaryCallable, so that
// TracedUnaryCallable can inject a tracer for the TracedBatcherUnaryCallable to interact with
UnaryCallable<Query, List<RowT>> tracedBatcher = new TracedBatcherUnaryCallable<>(readRowsUserCallable.all());
UnaryCallable<Query, List<RowT>> withHeaderTracer = new HeaderTracerUnaryCallable(tracedBatcher);
UnaryCallable<Query, List<RowT>> traced = new TracedUnaryCallable<>(withHeaderTracer, clientContext.getTracerFactory(), span);
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createReadModifyWriteRowCallable.
/**
* Creates a callable chain to handle ReadModifyWriteRow RPCs. The chain will:
*
* <ul>
* <li>Convert {@link ReadModifyWriteRow}s into {@link
* com.google.bigtable.v2.ReadModifyWriteRowRequest}s.
* <li>Convert the responses into {@link Row}.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<ReadModifyWriteRow, Row> createReadModifyWriteRowCallable() {
UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getReadModifyWriteRowMethod()).setParamsExtractor(new RequestParamsExtractor<ReadModifyWriteRowRequest>() {
@Override
public Map<String, String> extract(ReadModifyWriteRowRequest request) {
return ImmutableMap.of("table_name", request.getTableName(), "app_profile_id", request.getAppProfileId());
}
}).build(), settings.readModifyWriteRowSettings().getRetryableCodes());
UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
String methodName = "ReadModifyWriteRow";
UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
UnaryCallable<ReadModifyWriteRowRequest, ReadModifyWriteRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.readModifyWriteRowSettings(), clientContext);
return createUserFacingUnaryCallable(methodName, new ReadModifyWriteRowCallable(retrying, requestContext));
}
use of com.google.cloud.bigtable.data.v2.models.Row in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createReadRowsCallable.
/**
* Creates a callable chain to handle streaming 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.
* <li>Add tracing & metrics.
* </ul>
*/
public <RowT> ServerStreamingCallable<Query, RowT> createReadRowsCallable(RowAdapter<RowT> rowAdapter) {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable = createReadRowsBaseCallable(settings.readRowsSettings(), rowAdapter);
ServerStreamingCallable<Query, RowT> readRowsUserCallable = new ReadRowsUserCallable<>(readRowsCallable, requestContext);
SpanName span = getSpanName("ReadRows");
ServerStreamingCallable<Query, RowT> traced = new TracedServerStreamingCallable<>(readRowsUserCallable, clientContext.getTracerFactory(), span);
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
Aggregations