Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: extract all table related request params extractors #2402

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading