|
21 | 21 | import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.INSTANCE_ID_KEY;
|
22 | 22 |
|
23 | 23 | import com.google.api.core.ApiFunction;
|
| 24 | +import com.google.api.core.ApiFuture; |
24 | 25 | import com.google.api.core.BetaApi;
|
25 | 26 | import com.google.api.core.InternalApi;
|
26 | 27 | import com.google.api.gax.batching.Batcher;
|
|
39 | 40 | import com.google.api.gax.retrying.RetryAlgorithm;
|
40 | 41 | import com.google.api.gax.retrying.RetryingExecutorWithContext;
|
41 | 42 | import com.google.api.gax.retrying.ScheduledRetryingExecutor;
|
| 43 | +import com.google.api.gax.rpc.ApiCallContext; |
42 | 44 | import com.google.api.gax.rpc.Callables;
|
43 | 45 | import com.google.api.gax.rpc.ClientContext;
|
44 | 46 | import com.google.api.gax.rpc.RequestParamsExtractor;
|
|
98 | 100 | import com.google.cloud.bigtable.data.v2.models.RowMutation;
|
99 | 101 | import com.google.cloud.bigtable.data.v2.models.RowMutationEntry;
|
100 | 102 | import com.google.cloud.bigtable.data.v2.models.SampleRowKeysRequest;
|
| 103 | +import com.google.cloud.bigtable.data.v2.models.TableId; |
101 | 104 | import com.google.cloud.bigtable.data.v2.models.TargetId;
|
102 | 105 | import com.google.cloud.bigtable.data.v2.models.sql.Statement;
|
103 | 106 | import com.google.cloud.bigtable.data.v2.stub.changestream.ChangeStreamRecordMergingCallable;
|
@@ -194,7 +197,7 @@ public class EnhancedBigtableStub implements AutoCloseable {
|
194 | 197 | private final ServerStreamingCallable<Query, Row> readRowsCallable;
|
195 | 198 | private final UnaryCallable<Query, Row> readRowCallable;
|
196 | 199 | private final UnaryCallable<Query, List<Row>> bulkReadRowsCallable;
|
197 |
| - private final UnaryCallable<String, List<KeyOffset>> sampleRowKeysCallable; |
| 200 | + @Deprecated private final UnaryCallable<String, List<KeyOffset>> sampleRowKeysCallable; |
198 | 201 | private final UnaryCallable<SampleRowKeysRequest, List<KeyOffset>>
|
199 | 202 | sampleRowKeysCallableWithRequest;
|
200 | 203 | private final UnaryCallable<RowMutation, Void> mutateRowCallable;
|
@@ -698,11 +701,40 @@ private <RowT> UnaryCallable<Query, List<RowT>> createBulkReadRowsCallable(
|
698 | 701 | }
|
699 | 702 |
|
700 | 703 | /**
|
701 |
| - * Helper function that should only be used by createSampleRowKeysCallable() and |
702 |
| - * createSampleRowKeysWithRequestCallable(). |
| 704 | + * Simple wrapper around {@link #createSampleRowKeysCallableWithRequest()} to provide backwards |
| 705 | + * compatibility |
| 706 | + * |
| 707 | + * @deprecated |
| 708 | + */ |
| 709 | + @Deprecated |
| 710 | + private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() { |
| 711 | + UnaryCallable<SampleRowKeysRequest, List<KeyOffset>> baseCallable = |
| 712 | + createSampleRowKeysCallableWithRequest(); |
| 713 | + return new UnaryCallable<String, List<KeyOffset>>() { |
| 714 | + @Override |
| 715 | + public ApiFuture<List<KeyOffset>> futureCall(String s, ApiCallContext apiCallContext) { |
| 716 | + return baseCallable.futureCall(SampleRowKeysRequest.create(TableId.of(s)), apiCallContext); |
| 717 | + } |
| 718 | + }; |
| 719 | + } |
| 720 | + |
| 721 | + /** |
| 722 | + * Creates a callable chain to handle SampleRowKeys RPcs. The chain will: |
| 723 | + * |
| 724 | + * <ul> |
| 725 | + * <li>Convert a {@link SampleRowKeysRequest} to a {@link |
| 726 | + * com.google.bigtable.v2.SampleRowKeysRequest}. |
| 727 | + * <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}. |
| 728 | + * <li>Spool responses into a list. |
| 729 | + * <li>Retry on failure. |
| 730 | + * <li>Convert the responses into {@link KeyOffset}s. |
| 731 | + * <li>Add tracing & metrics. |
| 732 | + * </ul> |
703 | 733 | */
|
704 |
| - private UnaryCallable<com.google.bigtable.v2.SampleRowKeysRequest, List<SampleRowKeysResponse>> |
705 |
| - createSampleRowKeysBaseCallable() { |
| 734 | + private UnaryCallable<SampleRowKeysRequest, List<KeyOffset>> |
| 735 | + createSampleRowKeysCallableWithRequest() { |
| 736 | + String methodName = "SampleRowKeys"; |
| 737 | + |
706 | 738 | ServerStreamingCallable<com.google.bigtable.v2.SampleRowKeysRequest, SampleRowKeysResponse>
|
707 | 739 | base =
|
708 | 740 | GrpcRawCallableFactory.createServerStreamingCallable(
|
@@ -745,51 +777,8 @@ public Map<String, String> extract(
|
745 | 777 | UnaryCallable<com.google.bigtable.v2.SampleRowKeysRequest, List<SampleRowKeysResponse>>
|
746 | 778 | retryable = withRetries(withBigtableTracer, settings.sampleRowKeysSettings());
|
747 | 779 |
|
748 |
| - return retryable; |
749 |
| - } |
750 |
| - |
751 |
| - /** |
752 |
| - * Creates a callable chain to handle SampleRowKeys RPcs. The chain will: |
753 |
| - * |
754 |
| - * <ul> |
755 |
| - * <li>Convert a table id to a {@link com.google.bigtable.v2.SampleRowKeysRequest}. |
756 |
| - * <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}. |
757 |
| - * <li>Spool responses into a list. |
758 |
| - * <li>Retry on failure. |
759 |
| - * <li>Convert the responses into {@link KeyOffset}s. |
760 |
| - * <li>Add tracing & metrics. |
761 |
| - * </ul> |
762 |
| - */ |
763 |
| - private UnaryCallable<String, List<KeyOffset>> createSampleRowKeysCallable() { |
764 |
| - String methodName = "SampleRowKeys"; |
765 |
| - |
766 |
| - UnaryCallable<com.google.bigtable.v2.SampleRowKeysRequest, List<SampleRowKeysResponse>> |
767 |
| - baseCallable = createSampleRowKeysBaseCallable(); |
768 |
| - return createUserFacingUnaryCallable( |
769 |
| - methodName, new SampleRowKeysCallable(baseCallable, requestContext)); |
770 |
| - } |
771 |
| - |
772 |
| - /** |
773 |
| - * Creates a callable chain to handle SampleRowKeys RPcs. The chain will: |
774 |
| - * |
775 |
| - * <ul> |
776 |
| - * <li>Convert a {@link SampleRowKeysRequest} to a {@link |
777 |
| - * com.google.bigtable.v2.SampleRowKeysRequest}. |
778 |
| - * <li>Dispatch the request to the GAPIC's {@link BigtableStub#sampleRowKeysCallable()}. |
779 |
| - * <li>Spool responses into a list. |
780 |
| - * <li>Retry on failure. |
781 |
| - * <li>Convert the responses into {@link KeyOffset}s. |
782 |
| - * <li>Add tracing & metrics. |
783 |
| - * </ul> |
784 |
| - */ |
785 |
| - private UnaryCallable<SampleRowKeysRequest, List<KeyOffset>> |
786 |
| - createSampleRowKeysCallableWithRequest() { |
787 |
| - String methodName = "SampleRowKeys"; |
788 |
| - |
789 |
| - UnaryCallable<com.google.bigtable.v2.SampleRowKeysRequest, List<SampleRowKeysResponse>> |
790 |
| - baseCallable = createSampleRowKeysBaseCallable(); |
791 | 780 | return createUserFacingUnaryCallable(
|
792 |
| - methodName, new SampleRowKeysCallableWithRequest(baseCallable, requestContext)); |
| 781 | + methodName, new SampleRowKeysCallableWithRequest(retryable, requestContext)); |
793 | 782 | }
|
794 | 783 |
|
795 | 784 | /**
|
@@ -1470,6 +1459,8 @@ public UnaryCallable<Query, Row> readRowCallable() {
|
1470 | 1459 | return readRowCallable;
|
1471 | 1460 | }
|
1472 | 1461 |
|
| 1462 | + /** Deprecated, please use {@link #sampleRowKeysCallableWithRequest} */ |
| 1463 | + @Deprecated |
1473 | 1464 | public UnaryCallable<String, List<KeyOffset>> sampleRowKeysCallable() {
|
1474 | 1465 | return sampleRowKeysCallable;
|
1475 | 1466 | }
|
|
0 commit comments