Exists method added#3769
Conversation
| * }</pre> | ||
| */ | ||
| public boolean exists(String tableId) { | ||
| List<TableName> tableNames = this.listTables(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| String table = tableName.toString(); | ||
| String separator = "/"; | ||
| int index = table.lastIndexOf(separator); | ||
| String name = table.substring(index + separator.length()); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| boolean found = adminClient.exists(TABLE_NAME.getTable()); | ||
|
|
||
| // Verify | ||
| Assert.assertTrue(found); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
...ble-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java
Show resolved
Hide resolved
| return ApiFutures.transform(listTablesAsync(), new ApiFunction<List<TableName>, Boolean>() { | ||
| @Override public Boolean apply(List<TableName> tableNames) { | ||
| for(TableName tableName : tableNames) { | ||
| if(tableName.getTable().equalsIgnoreCase(tableId)) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return listTablesAsync(com.google.bigtable.admin.v2.Table.View.NAME_ONLY); | ||
| } | ||
|
|
||
| public ApiFuture<List<TableName>> listTablesAsync(com.google.bigtable.admin.v2.Table.View view) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| } | ||
|
|
||
| public ApiFuture<Boolean> existsAsync(final String tableId) { | ||
| return ApiFutures.transform(listTablesAsync(), new ApiFunction<List<TableName>, Boolean>() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
igorbernstein2
left a comment
There was a problem hiding this comment.
This looks pretty good, just needs some stylistic fixes
...igtable-admin/src/main/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClient.java
Show resolved
Hide resolved
| .setName(TABLE_NAME.toString()) | ||
| .build(); | ||
|
|
||
| Mockito.when(mockGetTableCallable.futureCall(Matchers.any(GetTableRequest.class))).thenReturn(ApiFutures.immediateFuture(expectedResponse)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| import com.google.bigtable.admin.v2.GetTableRequest; | ||
| import com.google.bigtable.admin.v2.InstanceName; | ||
| import com.google.bigtable.admin.v2.ListTablesRequest; | ||
| import com.google.bigtable.admin.v2.*; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // Setup | ||
| GetTableRequest expectedRequest = GetTableRequest.newBuilder() | ||
| .setName(TABLE_NAME.toString()) | ||
| .setView(com.google.bigtable.admin.v2.Table.View.SCHEMA_VIEW) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
...ble-admin/src/test/java/com/google/cloud/bigtable/admin/v2/BigtableTableAdminClientTest.java
Show resolved
Hide resolved
igorbernstein2
left a comment
There was a problem hiding this comment.
One last nit about sample code, but this LGTM
| * found, | ||
| * new ApiFutureCallback<Boolean>() { | ||
| * public void onSuccess(Boolean found) { | ||
| * System.out.println("Table exists"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
60e99f2 to
35da0af
Compare
| new NotFoundException("fake error", null, GrpcStatusCode.of(Status.Code.NOT_FOUND), false); | ||
|
|
||
| Mockito.when(mockGetTableCallable.futureCall(Matchers.any(GetTableRequest.class))) | ||
| .thenReturn(ApiFutures.immediateFailedFuture(exception)); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@elisheva-qlogic, there's a compilation failure:
It looks like a merge conflict with PR #3809 |
|
I think I fixed the issue |
….1 to 3.3.3 in /java-shared-dependencies/unmanaged-dependency-check (#3769) Bumps [org.apache.maven.shared:maven-shared-utils](https://github.com/apache/maven-shared-utils) from 3.2.1 to 3.3.3. <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/apache/maven-shared-utils/commit/cc010396156386d95e2acbc28f7aba32590243a2"><code>cc01039</code></a> [maven-release-plugin] prepare release maven-shared-utils-3.3.3</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/abdc90ccc36326dc6ee61ac497d2005e9e6637ef"><code>abdc90c</code></a> [maven-release-plugin] prepare for next development iteration</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/5460b13f6f4230d5ddce3fe8ffb241ab42254346"><code>5460b13</code></a> [maven-release-plugin] prepare release maven-shared-utils-3.3.2</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/60d005240b324e08661471fe6b0db981e2a0bd58"><code>60d0052</code></a> [maven-release-plugin] prepare for next development iteration</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/b3f78c16715d237b2d915d5cb963eef18b0d9fd2"><code>b3f78c1</code></a> [maven-release-plugin] prepare release maven-shared-utils-3.3.1</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/d1acca0bfaa7eda578f522f8d7851af074dbaa1c"><code>d1acca0</code></a> Bump version to 3.3.1 in preparation for release.</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/5ff997cac035ac7d2ab84bbd2c695c6e60798400"><code>5ff997c</code></a> [MSHARED-848] deprecate XmlStreamReader (<a href="https://redirect.github.com/apache/maven-shared-utils/issues/59">#59</a>)</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/914d9755b157f337dfb76e90f6b0331f834096d6"><code>914d975</code></a> remove call to deprecated method (<a href="https://redirect.github.com/apache/maven-shared-utils/issues/58">#58</a>)</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/dda9e1480f4f51120f619dfd302ed0d10807dfa5"><code>dda9e14</code></a> [MSHARED-904] update test dependencies for Maven 3.1 (<a href="https://redirect.github.com/apache/maven-shared-utils/issues/57">#57</a>)</li> <li><a href="https://github.com/apache/maven-shared-utils/commit/6798f3033c3c5144e52c5aa8e1be584ea97527d2"><code>6798f30</code></a> [MSHARED-297] - Minor code cleanup</li> <li>Additional commits viewable in <a href="https://github.com/apache/maven-shared-utils/compare/maven-shared-utils-3.2.1...maven-shared-utils-3.3.3">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/googleapis/sdk-platform-java/network/alerts). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Min Zhu <zhumin@google.com>
exists method added in BigtableTableAdminClient to check if table exists #3636