@Test public void testReadRowAsync() throws Exception { Query query = Query.create(TABLE_ID).rowKey("non-existent-key").limit(1L); when(delegate.readFlatRowsAsync(query.toProto(REQUEST_CONTEXT))) .thenReturn(Futures.immediateFuture(Collections.<FlatRow>emptyList())); Result result = dataClientWrapper .readRowAsync(TABLE_ID, ByteString.copyFromUtf8("non-existent-key"), null) .get(); assertEquals(Result.EMPTY_RESULT, result); Filters.Filter filter = Filters.FILTERS.family().exactMatch("cf"); Query queryWithFilter = Query.create(TABLE_ID).rowKey(ROW_KEY).filter(filter).limit(1L); when(delegate.readFlatRowsAsync(queryWithFilter.toProto(REQUEST_CONTEXT))) .thenReturn(Futures.immediateFuture(Collections.singletonList(SAMPLE_FLAT_ROW))); Result actualResult = dataClientWrapper.readRowAsync(TABLE_ID, ROW_KEY, filter).get(); assertArrayEquals( FLAT_ROW_ADAPTER.adaptResponse(SAMPLE_FLAT_ROW).rawCells(), actualResult.rawCells()); verify(delegate).readFlatRowsAsync(query.toProto(REQUEST_CONTEXT)); verify(delegate).readFlatRowsAsync(queryWithFilter.toProto(REQUEST_CONTEXT)); }
@Override public ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter) { Query request = Query.create(tableId).rowKey(rowKey).limit(1L); if (filter != null) { request.filter(filter); } return ApiFutureUtil.transformAndAdapt( delegate.readFlatRowsAsync(request.toProto(requestContext)), new Function<List<FlatRow>, Result>() { @Override public Result apply(List<FlatRow> flatRows) { if (flatRows.isEmpty()) { return Result.EMPTY_RESULT; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRows.get(0)); } }); }
DataClientClassicApi implements DataClientWrapper { @Override public ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter) { Query request = Query.create(tableId).rowKey(rowKey).limit(1L); if (filter != null) { request.filter(filter); } return ApiFutureUtil.transformAndAdapt( delegate.readFlatRowsAsync(request.toProto(requestContext)), new Function<List<FlatRow>, Result>() { @Override public Result apply(List<FlatRow> flatRows) { if (flatRows.isEmpty()) { return Result.EMPTY_RESULT; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRows.get(0)); } }); } }
DataClientClassicApi implements DataClientWrapper { @Override public ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter) { Query request = Query.create(tableId).rowKey(rowKey).limit(1L); if (filter != null) { request.filter(filter); } return ApiFutureUtil.transformAndAdapt( delegate.readFlatRowsAsync(request.toProto(requestContext)), new Function<List<FlatRow>, Result>() { @Override public Result apply(List<FlatRow> flatRows) { if (flatRows.isEmpty()) { return Result.EMPTY_RESULT; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRows.get(0)); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); }
DataClientClassicApi implements DataClientWrapper { @Override public ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter) { Query request = Query.create(tableId).rowKey(rowKey).limit(1L); if (filter != null) { request.filter(filter); } return ApiFutureUtil.transformAndAdapt( delegate.readFlatRowsAsync(request.toProto(requestContext)), new Function<List<FlatRow>, Result>() { @Override public Result apply(List<FlatRow> flatRows) { if (flatRows.isEmpty()) { return Result.EMPTY_RESULT; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRows.get(0)); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); @Override BulkMutationWrapper createBulkMutation(String tableId); @Override BulkReadWrapper createBulkRead(String tableId); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override ApiFuture<Result> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter); @Override org.apache.hadoop.hbase.client.ResultScanner readRows(Query request); @Override ApiFuture<List<Result>> readRowsAsync(Query request); @Override void readRowsAsync(Query request, final StreamObserver<Result> observer); @Override void close(); }
DataClientClassicApi implements DataClientWrapper { @Override public ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter) { Query request = Query.create(tableId).rowKey(rowKey).limit(1L); if (filter != null) { request.filter(filter); } return ApiFutureUtil.transformAndAdapt( delegate.readFlatRowsAsync(request.toProto(requestContext)), new Function<List<FlatRow>, Result>() { @Override public Result apply(List<FlatRow> flatRows) { if (flatRows.isEmpty()) { return Result.EMPTY_RESULT; } return Adapters.FLAT_ROW_ADAPTER.adaptResponse(flatRows.get(0)); } }); } DataClientClassicApi(BigtableSession session, RequestContext requestContext); @Override BulkMutationWrapper createBulkMutation(String tableId); @Override BulkReadWrapper createBulkRead(String tableId); @Override ApiFuture<Void> mutateRowAsync(RowMutation rowMutation); @Override ApiFuture<Result> readModifyWriteRowAsync(ReadModifyWriteRow readModifyWriteRow); @Override ApiFuture<Boolean> checkAndMutateRowAsync(ConditionalRowMutation conditionalRowMutation); @Override ApiFuture<List<KeyOffset>> sampleRowKeysAsync(String tableId); @Override ApiFuture<Result> readRowAsync(String tableId, ByteString rowKey, Filters.Filter filter); @Override org.apache.hadoop.hbase.client.ResultScanner readRows(Query request); @Override ApiFuture<List<Result>> readRowsAsync(Query request); @Override void readRowsAsync(Query request, final StreamObserver<Result> observer); @Override void close();  }