Skip to content

Commit

Permalink
extract all table related request params extractors
Browse files Browse the repository at this point in the history
Change-Id: I22910ebd8024eecf623fee595596fa53e4ec59f5
  • Loading branch information
igorbernstein2 committed Nov 4, 2024
1 parent b40828c commit 61895b9
Showing 1 changed file with 12 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,22 +603,9 @@ private <ReqT, RowT> ServerStreamingCallable<ReadRowsRequest, RowT> createReadRo
GrpcCallSettings.<ReadRowsRequest, ReadRowsResponse>newBuilder()
.setMethodDescriptor(BigtableGrpc.getReadRowsMethod())
.setParamsExtractor(
new RequestParamsExtractor<ReadRowsRequest>() {
@Override
public Map<String, String> extract(ReadRowsRequest readRowsRequest) {
String tableName = readRowsRequest.getTableName();
String authorizedViewName = readRowsRequest.getAuthorizedViewName();
if (tableName.isEmpty()) {
tableName =
NameUtil.extractTableNameFromAuthorizedViewName(authorizedViewName);
}
return ImmutableMap.of(
"table_name",
tableName,
"app_profile_id",
readRowsRequest.getAppProfileId());
}
})
r ->
composeRequestParams(
r.getAppProfileId(), r.getTableName(), r.getAuthorizedViewName()))
.build(),
readRowsSettings.getRetryableCodes());

Expand Down Expand Up @@ -742,25 +729,9 @@ public ApiFuture<List<KeyOffset>> futureCall(String s, ApiCallContext apiCallCon
newBuilder()
.setMethodDescriptor(BigtableGrpc.getSampleRowKeysMethod())
.setParamsExtractor(
new RequestParamsExtractor<com.google.bigtable.v2.SampleRowKeysRequest>() {
@Override
public Map<String, String> extract(
com.google.bigtable.v2.SampleRowKeysRequest sampleRowKeysRequest) {
String tableName = sampleRowKeysRequest.getTableName();
String authorizedViewName =
sampleRowKeysRequest.getAuthorizedViewName();
if (tableName.isEmpty()) {
tableName =
NameUtil.extractTableNameFromAuthorizedViewName(
authorizedViewName);
}
return ImmutableMap.of(
"table_name",
tableName,
"app_profile_id",
sampleRowKeysRequest.getAppProfileId());
}
})
r ->
composeRequestParams(
r.getAppProfileId(), r.getTableName(), r.getAuthorizedViewName()))
.build(),
settings.sampleRowKeysSettings().getRetryableCodes());

Expand Down Expand Up @@ -823,22 +794,9 @@ private UnaryCallable<BulkMutation, MutateRowsAttemptResult> createMutateRowsBas
GrpcCallSettings.<MutateRowsRequest, MutateRowsResponse>newBuilder()
.setMethodDescriptor(BigtableGrpc.getMutateRowsMethod())
.setParamsExtractor(
new RequestParamsExtractor<MutateRowsRequest>() {
@Override
public Map<String, String> extract(MutateRowsRequest mutateRowsRequest) {
String tableName = mutateRowsRequest.getTableName();
String authorizedViewName = mutateRowsRequest.getAuthorizedViewName();
if (tableName.isEmpty()) {
tableName =
NameUtil.extractTableNameFromAuthorizedViewName(authorizedViewName);
}
return ImmutableMap.of(
"table_name",
tableName,
"app_profile_id",
mutateRowsRequest.getAppProfileId());
}
})
r ->
composeRequestParams(
r.getAppProfileId(), r.getTableName(), r.getAuthorizedViewName()))
.build(),
settings.bulkMutateRowsSettings().getRetryableCodes());

Expand Down Expand Up @@ -1075,18 +1033,7 @@ private UnaryCallable<ReadModifyWriteRow, Row> createReadModifyWriteRowCallable(
.setMethodDescriptor(
BigtableGrpc.getGenerateInitialChangeStreamPartitionsMethod())
.setParamsExtractor(
new RequestParamsExtractor<GenerateInitialChangeStreamPartitionsRequest>() {
@Override
public Map<String, String> extract(
GenerateInitialChangeStreamPartitionsRequest
generateInitialChangeStreamPartitionsRequest) {
return ImmutableMap.of(
"table_name",
generateInitialChangeStreamPartitionsRequest.getTableName(),
"app_profile_id",
generateInitialChangeStreamPartitionsRequest.getAppProfileId());
}
})
r -> composeRequestParams(r.getAppProfileId(), r.getTableName(), ""))
.build(),
settings.generateInitialChangeStreamPartitionsSettings().getRetryableCodes());

Expand Down Expand Up @@ -1155,15 +1102,7 @@ public Map<String, String> extract(
GrpcCallSettings.<ReadChangeStreamRequest, ReadChangeStreamResponse>newBuilder()
.setMethodDescriptor(BigtableGrpc.getReadChangeStreamMethod())
.setParamsExtractor(
new RequestParamsExtractor<ReadChangeStreamRequest>() {
@Override
public Map<String, String> extract(
ReadChangeStreamRequest readChangeStreamRequest) {
return ImmutableMap.of(
"table_name", readChangeStreamRequest.getTableName(),
"app_profile_id", readChangeStreamRequest.getAppProfileId());
}
})
r -> composeRequestParams(r.getAppProfileId(), r.getTableName(), ""))
.build(),
settings.readChangeStreamSettings().getRetryableCodes());

Expand Down Expand Up @@ -1313,7 +1252,7 @@ private <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> createUserFacin

private Map<String, String> composeRequestParams(
String appProfileId, String tableName, String authorizedViewName) {
if (tableName.isEmpty()) {
if (tableName.isEmpty() && !authorizedViewName.isEmpty()) {
tableName = NameUtil.extractTableNameFromAuthorizedViewName(authorizedViewName);
}
return ImmutableMap.of("table_name", tableName, "app_profile_id", appProfileId);
Expand Down

0 comments on commit 61895b9

Please sign in to comment.