@Override @Nullable public Struct readRowUsingIndex(String table, String index, Key key, Iterable<String> columns) { try { session.markUsed(); return delegate.readRowUsingIndex(table, index, key, columns); } finally { if (isSingleUse) { close(); } } }
Struct readRowUsingIndex() { // [START read_context_read_index] ReadContext readContext = dbClient.singleUse(); Struct row = readContext.readRowUsingIndex( "Albums", "AlbumsByAlbumId", Key.of(1, "Green"), Arrays.asList("AlbumId", "AlbumTitle")); // [END read_context_read_index] return row; }
@Test public void indexPointReadNotFound() { Struct row = client .singleUse(TimestampBound.strong()) .readRowUsingIndex(TABLE_NAME, INDEX_NAME, Key.of("v999"), ALL_COLUMNS); assertThat(row).isNull(); }
@Test public void indexPointRead() { Struct row = client .singleUse(TimestampBound.strong()) .readRowUsingIndex(TABLE_NAME, INDEX_NAME, Key.of("v1"), ALL_COLUMNS); assertThat(row).isNotNull(); assertThat(row.getString(0)).isEqualTo("k1"); assertThat(row.getString(1)).isEqualTo("v1"); }
@Nullable @Override public Struct readRowUsingIndex( String s, String s1, Key key, Iterable<String> iterable) { return targetTransactionContext.readRowUsingIndex(s, s1, key, iterable); }
@Nullable @Override public Struct readRowUsingIndex( String s, String s1, Key key, Iterable<String> iterable) { return targetTransactionContext.readRowUsingIndex(s, s1, key, iterable); }
@Override @Nullable public Struct readRowUsingIndex(String table, String index, Key key, Iterable<String> columns) { try { session.markUsed(); return delegate.readRowUsingIndex(table, index, key, columns); } finally { if (isSingleUse) { close(); } } }