BatchExecutor { public <R> void batchCallback( List<? extends Row> actions, Object[] results, Batch.Callback<R> callback) throws IOException, InterruptedException { Preconditions.checkArgument( results == null || results.length == actions.size(), "Result array must have same dimensions as actions list."); if (actions.isEmpty()) { return; } if (results == null) { results = new Object[actions.size()]; } Timer.Context timerContext = batchTimer.time(); List<ApiFuture<?>> resultFutures = issueAsyncRowRequests(actions, results, callback); List<Throwable> problems = new ArrayList<>(); List<Row> problemActions = new ArrayList<>(); List<String> hosts = new ArrayList<>(); for (int i = 0; i < resultFutures.size(); i++) { try { resultFutures.get(i).get(); } catch (ExecutionException e) { problemActions.add(actions.get(i)); problems.add(e.getCause()); hosts.add(settings.getDataHost()); } } if (problems.size() > 0) { throw new RetriesExhaustedWithDetailsException(problems, problemActions, hosts); } timerContext.close(); } BatchExecutor(
      BigtableApi bigtableApi, BigtableHBaseSettings settings, HBaseRequestAdapter adapter); void batch(List<? extends Row> actions, @Nullable Object[] results); List<ApiFuture<?>> issueAsyncRowRequests(
      List<? extends Row> actions, Object[] results, Batch.Callback<R> callback); Result[] batch(List<? extends Row> actions); void batchCallback(
      List<? extends Row> actions, Object[] results, Batch.Callback<R> callback); boolean[] exists(List<Get> gets); static final byte[] NO_REGION; }
@Test public void testGetCallback() throws Exception { when(mockBulkRead.add(any(ByteString.class), any(Filters.Filter.class))).thenReturn(mockFuture); byte[] key = randomBytes(8); Result response = Result.create( ImmutableList.<Cell>of( new RowCell( key, Bytes.toBytes("family"), Bytes.toBytes(""), 1000L, Bytes.toBytes("value")))); setFuture(response); final Callback<Result> callback = Mockito.mock(Callback.class); createExecutor().batchCallback(ImmutableList.<Row>of(new Get(key)), new Object[1], callback); verify(callback, times(1)) .update(same(BatchExecutor.NO_REGION), same(key), argThat(matchesRow(response))); }