BigtableDataClientWrapper implements IBigtableDataClient { @Override public List<KeyOffset> sampleRowKeys(String tableId) { String fullTableName = NameUtil.formatTableName( requestContext.getProjectId(), requestContext.getInstanceId(), tableId); SampleRowKeysRequest requestProto = SampleRowKeysRequest.newBuilder().setTableName(fullTableName).build(); List<SampleRowKeysResponse> responseProto = delegate.sampleRowKeys(requestProto); ImmutableList.Builder<KeyOffset> keyOffsetBuilder = ImmutableList.builderWithExpectedSize(responseProto.size()); for (SampleRowKeysResponse rowKeys : responseProto) { keyOffsetBuilder.add(KeyOffset.create(rowKeys.getRowKey(), rowKeys.getOffsetBytes())); } return keyOffsetBuilder.build(); } BigtableDataClientWrapper(
      BigtableDataClient bigtableDataClient, RequestContext requestContext); @Override void mutateRow(RowMutation rowMutation); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override Row readModifyWriteRow(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Row> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override IBulkMutation createBulkMutationBatcher(String tableId); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override Boolean checkAndMutateRow(ConditionalRowMutation conditionalRowMutation); @Override List<KeyOffset> sampleRowKeys(String tableId); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ResultScanner<Row> readRows(Query request); @Override ApiFuture<List<Row>> readRowsAsync(Query request); @Override List<FlatRow> readFlatRowsList(Query request); @Override ResultScanner<FlatRow> readFlatRows(Query request); @Override ApiFuture<List<FlatRow>> readFlatRowsAsync(Query request); @Override void readFlatRowsAsync(Query request, StreamObserver<FlatRow> observer);  }
@Test public void testSampleRowKeys() { final ByteString ROW_KEY_1 = ByteString.copyFromUtf8("row-key-1"); final ByteString ROW_KEY_2 = ByteString.copyFromUtf8("row-key-2"); final ByteString ROW_KEY_3 = ByteString.copyFromUtf8("row-key-3"); String tableName = NameUtil.formatTableName(PROJECT_ID, INSTANCE_ID, TABLE_ID); SampleRowKeysRequest requestProto = SampleRowKeysRequest.newBuilder().setTableName(tableName).build(); ImmutableList.Builder sampleKeys = ImmutableList.builder(); sampleKeys.add( SampleRowKeysResponse.newBuilder().setRowKey(ROW_KEY_1).setOffsetBytes(11).build()); sampleKeys.add( SampleRowKeysResponse.newBuilder().setRowKey(ROW_KEY_2).setOffsetBytes(12).build()); sampleKeys.add( SampleRowKeysResponse.newBuilder().setRowKey(ROW_KEY_3).setOffsetBytes(13).build()); when(client.sampleRowKeys(requestProto)).thenReturn(sampleKeys.build()); List<KeyOffset> keyOffsetList = clientWrapper.sampleRowKeys(TABLE_ID); assertEquals(keyOffsetList.get(0).getKey(), ROW_KEY_1); assertEquals(keyOffsetList.get(1).getKey(), ROW_KEY_2); assertEquals(keyOffsetList.get(2).getKey(), ROW_KEY_3); verify(client).sampleRowKeys(requestProto); }