Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 95a9a3f

Browse files
improve view name formating
Change-Id: I85e271194cfada199186db271b042eeedf9fd7cf
1 parent 79206d6 commit 95a9a3f

7 files changed

Lines changed: 88 additions & 112 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/NameUtil.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static String formatTableName(
5050

5151
public static String formatTableName(
5252
@Nonnull String projectId, @Nonnull String instanceId, @Nonnull TableId tableId) {
53-
return formatInstanceName(projectId, instanceId) + "/tables/" + tableId.getTableId();
53+
return formatTableName(projectId, instanceId, tableId.getTableId());
5454
}
5555

5656
public static String formatAuthorizedViewName(
@@ -64,16 +64,26 @@ public static String formatAuthorizedViewName(
6464
public static String formatAuthorizedViewName(
6565
@Nonnull String projectId,
6666
@Nonnull String instanceId,
67-
@Nonnull TableId tableId,
68-
@Nonnull String authorizedViewId) {
69-
return formatTableName(projectId, instanceId, tableId) + "/authorizedViews/" + authorizedViewId;
67+
@Nonnull AuthorizedViewId authorizedViewId) {
68+
return formatTableName(projectId, instanceId, authorizedViewId.getTableId())
69+
+ "/authorizedViews/"
70+
+ authorizedViewId.getAuthorizedViewId();
7071
}
7172

7273
public static String formatMaterializedViewName(
7374
@Nonnull String projectId, @Nonnull String instanceId, @Nonnull String materializedViewId) {
7475
return formatInstanceName(projectId, instanceId) + "/materializedViews/" + materializedViewId;
7576
}
7677

78+
public static String formatMaterializedViewName(
79+
@Nonnull String projectId,
80+
@Nonnull String instanceId,
81+
@Nonnull MaterializedViewId materializedViewId) {
82+
return formatInstanceName(projectId, instanceId)
83+
+ "/materializedViews/"
84+
+ materializedViewId.getMaterializedViewId();
85+
}
86+
7787
public static String extractTableIdFromTableName(@Nonnull String fullTableName) {
7888
Matcher matcher = TABLE_PATTERN.matcher(fullTableName);
7989
if (!matcher.matches()) {

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/AuthorizedViewId.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public static AuthorizedViewId of(TableId tableId, String authorizedViewId) {
4242
return new AutoValue_AuthorizedViewId(tableId.getTableId(), authorizedViewId);
4343
}
4444

45-
abstract String getTableId();
45+
public abstract String getTableId();
4646

47-
abstract String getAuthorizedViewId();
47+
public abstract String getAuthorizedViewId();
4848

4949
@Override
5050
@InternalApi

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/models/MaterializedViewId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static MaterializedViewId of(String materializedViewId) {
3535
return new AutoValue_MaterializedViewId(materializedViewId);
3636
}
3737

38-
abstract String getMaterializedViewId();
38+
public abstract String getMaterializedViewId();
3939

4040
@Override
4141
@InternalApi

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/internal/csm/tracers/BuiltinMetricsTracerTest.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsTestUtils.verifyAttributes;
2222
import static com.google.common.truth.Truth.assertThat;
2323
import static com.google.common.truth.Truth.assertWithMessage;
24+
import static org.junit.Assert.assertThrows;
2425

2526
import com.google.api.client.util.Lists;
2627
import com.google.api.core.ApiFunction;
@@ -119,7 +120,6 @@
119120
import java.util.stream.Collectors;
120121
import javax.annotation.Nullable;
121122
import org.junit.After;
122-
import org.junit.Assert;
123123
import org.junit.Before;
124124
import org.junit.Rule;
125125
import org.junit.Test;
@@ -367,6 +367,7 @@ public void onResponse(Row response) {
367367
try {
368368
Thread.sleep(100);
369369
} catch (InterruptedException ignored) {
370+
// dont really care
370371
}
371372
}
372373

@@ -455,10 +456,11 @@ public void onStart(StreamController streamController) {}
455456

456457
@Override
457458
public void onResponse(Row row) {
459+
counter.getAndIncrement();
458460
try {
459-
counter.getAndIncrement();
460461
Thread.sleep(APPLICATION_LATENCY);
461462
} catch (InterruptedException ignored) {
463+
// dont really care
462464
}
463465
}
464466

@@ -603,7 +605,7 @@ public void testMutateRowsPartialError() throws InterruptedException {
603605
batcher.add(RowMutationEntry.create(key).setCell("f", "q", "v"));
604606
}
605607

606-
Assert.assertThrows(BatchingException.class, batcher::close);
608+
assertThrows(BatchingException.class, batcher::close);
607609

608610
MetricData metricData = getMetricData(metricReader, TableAttemptLatency.NAME);
609611

@@ -631,7 +633,7 @@ public void testMutateRowsRpcError() {
631633
batcher.add(RowMutationEntry.create(key).setCell("f", "q", "v"));
632634
}
633635

634-
Assert.assertThrows(BatchingException.class, batcher::close);
636+
assertThrows(BatchingException.class, batcher::close);
635637

636638
MetricData metricData = getMetricData(metricReader, TableAttemptLatency.NAME);
637639

@@ -767,12 +769,11 @@ public void testQueuedOnChannelUnaryLatencies() throws Exception {
767769

768770
@Test
769771
public void testPermanentFailure() {
770-
try {
771-
Lists.newArrayList(
772-
stub.readRowsCallable().call(Query.create(TableId.of(BAD_TABLE_ID))).iterator());
773-
Assert.fail("Request should throw not found error");
774-
} catch (NotFoundException ignored) {
775-
}
772+
assertThrows(
773+
NotFoundException.class,
774+
() ->
775+
Lists.newArrayList(
776+
stub.readRowsCallable().call(Query.create(TableId.of(BAD_TABLE_ID))).iterator()));
776777

777778
MetricData attemptLatency = getMetricData(metricReader, TableAttemptLatency.NAME);
778779

@@ -1054,6 +1055,7 @@ public void readRows(
10541055
try {
10551056
Thread.sleep(SERVER_LATENCY);
10561057
} catch (InterruptedException ignored) {
1058+
// dont care
10571059
}
10581060
if (attemptCounter.getAndIncrement() == 0) {
10591061
target.onError(new StatusRuntimeException(Status.UNAVAILABLE));
@@ -1096,6 +1098,7 @@ public void mutateRows(
10961098
try {
10971099
Thread.sleep(SERVER_LATENCY);
10981100
} catch (InterruptedException ignored) {
1101+
// dont care
10991102
}
11001103
MutateRowsResponse.Builder builder = MutateRowsResponse.newBuilder();
11011104
String receivedRowkey = "";
@@ -1208,7 +1211,7 @@ public ProxiedSocketAddress proxyFor(SocketAddress socketAddress) throws IOExcep
12081211
try {
12091212
Thread.sleep(CHANNEL_BLOCKING_LATENCY.toMillis());
12101213
} catch (InterruptedException ignored) {
1211-
1214+
// dont care
12121215
}
12131216
return null;
12141217
}

0 commit comments

Comments
 (0)