use of com.google.bigtable.v2.RowFilter.Chain in project java-bigtable-hbase by googleapis.
the class TestSingleColumnValueFilterAdapter method assertColumnSpecification.
// Assert that the given family, qualifier and versions are applied
// via the given Chain.
private static void assertColumnSpecification(byte[] family, byte[] qualifier, boolean latestOnly, RowFilter filter) throws IOException {
Chain chain = filter.getChain();
Assert.assertEquals(Bytes.toString(family), chain.getFilters(0).getFamilyNameRegexFilter());
Assert.assertArrayEquals(qualifier, chain.getFilters(1).getColumnQualifierRegexFilter().toByteArray());
if (latestOnly) {
Assert.assertEquals(FILTERS.limit().cellsPerColumn(1).toProto(), chain.getFilters(2));
}
}
use of com.google.bigtable.v2.RowFilter.Chain in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createMutateRowCallable.
/**
* Creates a callable chain to handle MutateRow RPCs. The chain will:
*
* <ul>
* <li>Convert a {@link RowMutation} into a {@link com.google.bigtable.v2.MutateRowRequest}.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<RowMutation, Void> createMutateRowCallable() {
String methodName = "MutateRow";
UnaryCallable<MutateRowRequest, MutateRowResponse> base = GrpcRawCallableFactory.createUnaryCallable(GrpcCallSettings.<MutateRowRequest, MutateRowResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getMutateRowMethod()).setParamsExtractor(new RequestParamsExtractor<MutateRowRequest>() {
@Override
public Map<String, String> extract(MutateRowRequest mutateRowRequest) {
return ImmutableMap.of("table_name", mutateRowRequest.getTableName(), "app_profile_id", mutateRowRequest.getAppProfileId());
}
}).build(), settings.mutateRowSettings().getRetryableCodes());
UnaryCallable<MutateRowRequest, MutateRowResponse> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);
UnaryCallable<MutateRowRequest, MutateRowResponse> withHeaderTracer = new HeaderTracerUnaryCallable<>(withStatsHeaders);
UnaryCallable<MutateRowRequest, MutateRowResponse> retrying = Callables.retrying(withHeaderTracer, settings.mutateRowSettings(), clientContext);
return createUserFacingUnaryCallable(methodName, new MutateRowCallable(retrying, requestContext));
}
use of com.google.bigtable.v2.RowFilter.Chain in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createBulkMutateRowsCallable.
/**
* Creates a callable chain to handle MutatesRows RPCs. This is meant to be used for manual
* batching. The chain will:
*
* <ul>
* <li>Convert a {@link BulkMutation} into a {@link MutateRowsRequest}.
* <li>Process the response and schedule retries. At the end of each attempt, entries that have
* been applied, are filtered from the next attempt. Also, any entries that failed with a
* nontransient error, are filtered from the next attempt. This will continue until there
* are no more entries or there are no more retry attempts left.
* <li>Wrap batch failures in a {@link
* com.google.cloud.bigtable.data.v2.models.MutateRowsException}.
* <li>Add tracing & metrics.
* </ul>
*/
private UnaryCallable<BulkMutation, Void> createBulkMutateRowsCallable() {
UnaryCallable<MutateRowsRequest, Void> baseCallable = createMutateRowsBaseCallable();
UnaryCallable<MutateRowsRequest, Void> flowControlCallable = null;
if (settings.bulkMutateRowsSettings().isLatencyBasedThrottlingEnabled()) {
flowControlCallable = new DynamicFlowControlCallable(baseCallable, bulkMutationFlowController, bulkMutationDynamicFlowControlStats, settings.bulkMutateRowsSettings().getTargetRpcLatencyMs(), FLOW_CONTROL_ADJUSTING_INTERVAL_MS);
}
UnaryCallable<BulkMutation, Void> userFacing = new BulkMutateRowsUserFacingCallable(flowControlCallable != null ? flowControlCallable : baseCallable, requestContext);
SpanName spanName = getSpanName("MutateRows");
UnaryCallable<BulkMutation, Void> tracedBatcher = new TracedBatcherUnaryCallable<>(userFacing);
UnaryCallable<BulkMutation, Void> withHeaderTracer = new HeaderTracerUnaryCallable<>(tracedBatcher);
UnaryCallable<BulkMutation, Void> traced = new TracedUnaryCallable<>(withHeaderTracer, clientContext.getTracerFactory(), spanName);
return traced.withDefaultCallContext(clientContext.getDefaultCallContext());
}
use of com.google.bigtable.v2.RowFilter.Chain in project java-bigtable by googleapis.
the class EnhancedBigtableStub method createMutateRowsBaseCallable.
/**
* Internal helper to create the base MutateRows callable chain. The chain is responsible for
* retrying individual entry in case of error.
*
* <p>NOTE: the caller is responsible for adding tracing & metrics.
*
* @see MutateRowsRetryingCallable for more details
*/
private UnaryCallable<MutateRowsRequest, Void> createMutateRowsBaseCallable() {
ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> base = GrpcRawCallableFactory.createServerStreamingCallable(GrpcCallSettings.<MutateRowsRequest, MutateRowsResponse>newBuilder().setMethodDescriptor(BigtableGrpc.getMutateRowsMethod()).setParamsExtractor(new RequestParamsExtractor<MutateRowsRequest>() {
@Override
public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {
return ImmutableMap.of("table_name", mutateRowsRequest.getTableName(), "app_profile_id", mutateRowsRequest.getAppProfileId());
}
}).build(), settings.bulkMutateRowsSettings().getRetryableCodes());
ServerStreamingCallable<MutateRowsRequest, MutateRowsResponse> withStatsHeaders = new StatsHeadersServerStreamingCallable<>(base);
RetryAlgorithm<Void> retryAlgorithm = new RetryAlgorithm<>(new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm(settings.bulkMutateRowsSettings().getRetrySettings(), clientContext.getClock()));
RetryingExecutorWithContext<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor());
return new MutateRowsRetryingCallable(clientContext.getDefaultCallContext(), withStatsHeaders, retryingExecutor, settings.bulkMutateRowsSettings().getRetryableCodes());
}
use of com.google.bigtable.v2.RowFilter.Chain in project java-bigtable-hbase by googleapis.
the class TestKeyOnlyFilterAdapter method stripValuesIsApplied.
@Test
public void stripValuesIsApplied() throws IOException {
KeyOnlyFilter filter = new KeyOnlyFilter();
Filters.Filter expectedFilter = filterAdapter.adapt(emptyScanContext, filter);
Chain chain = expectedFilter.toProto().getChain();
Assert.assertTrue(chain.getFilters(0).getStripValueTransformer() || chain.getFilters(1).getStripValueTransformer());
Filters.Filter filters = filterAdapter.adapt(emptyScanContext, filter);
Filters f = Filters.FILTERS;
Assert.assertEquals(filters.toProto(), f.chain().filter(f.limit().cellsPerColumn(1)).filter(f.value().strip()).toProto());
}
Aggregations