diff --git a/src/main/java/com/google/cloud/anviltop/hbase/AnvilTopTable.java b/src/main/java/com/google/cloud/anviltop/hbase/AnvilTopTable.java index 59039ab3a7..8a5af77346 100644 --- a/src/main/java/com/google/cloud/anviltop/hbase/AnvilTopTable.java +++ b/src/main/java/com/google/cloud/anviltop/hbase/AnvilTopTable.java @@ -163,9 +163,7 @@ public Boolean[] exists(List gets) throws IOException { @Override public void batch(List actions, Object[] results) throws IOException, InterruptedException { - Result[] tempResults = new Result[results.length]; - batchExecutor.batch(actions, tempResults); - System.arraycopy(tempResults, 0, results, 0, results.length); + batchExecutor.batch(actions, results); } @Override @@ -176,9 +174,7 @@ public Object[] batch(List actions) throws IOException, Interrupt @Override public void batchCallback(List actions, Object[] results, Batch.Callback callback) throws IOException, InterruptedException { - Result[] tempResults = new Result[results.length]; - batchExecutor.batchCallback(actions, tempResults, callback); - System.arraycopy(tempResults, 0, results, 0, results.length); + batchExecutor.batchCallback(actions, results, callback); } @Override @@ -211,7 +207,7 @@ public Result get(Get get) throws IOException { @Override public Result[] get(List gets) throws IOException { - return batchExecutor.batch(gets); + return (Result[]) batchExecutor.batch(gets); } @Override diff --git a/src/main/java/com/google/cloud/anviltop/hbase/BatchExecutor.java b/src/main/java/com/google/cloud/anviltop/hbase/BatchExecutor.java index 9a04c2190d..d5c92bcf1a 100644 --- a/src/main/java/com/google/cloud/anviltop/hbase/BatchExecutor.java +++ b/src/main/java/com/google/cloud/anviltop/hbase/BatchExecutor.java @@ -65,14 +65,14 @@ static abstract class RpcResultFutureCallback private final Row row; private final Batch.Callback callback; private final int index; - private final Result[] resultsArray; + private final Object[] resultsArray; private final SettableFuture resultFuture; public RpcResultFutureCallback( Row row, Batch.Callback callback, int index, - Result[] resultsArray, + Object[] resultsArray, SettableFuture resultFuture) { this.row = row; this.callback = callback; @@ -84,7 +84,7 @@ public RpcResultFutureCallback( /** * Adapt a proto result into a client result */ - abstract Result adaptResponse(T response); + abstract Object adaptResponse(T response); @SuppressWarnings("unchecked") R unchecked(Object o) { @@ -94,7 +94,7 @@ R unchecked(Object o) { @Override public void onSuccess(T t) { try { - Result result = adaptResponse(t); + Object result = adaptResponse(t); resultsArray[index] = result; if (callback != null) { callback.update(NO_REGION, row.getRow(), unchecked(result)); @@ -321,7 +321,7 @@ ListenableFuture issueRowMutationsRequest( * @return A ListenableFuture that will have the result when the RPC completes. */ ListenableFuture issueRowRequest( - final Row row, final Batch.Callback callback, final Result[] results, final int index) { + final Row row, final Batch.Callback callback, final Object[] results, final int index) { final SettableFuture resultFuture = SettableFuture.create(); results[index] = null; if (row instanceof Delete) { @@ -331,7 +331,7 @@ ListenableFuture issueRowRequest( new RpcResultFutureCallback( row, callback, index, results, resultFuture) { @Override - Result adaptResponse(AnviltopServices.MutateRowResponse response) { + Object adaptResponse(AnviltopServices.MutateRowResponse response) { return new Result(); } }, @@ -343,7 +343,7 @@ Result adaptResponse(AnviltopServices.MutateRowResponse response) { new RpcResultFutureCallback( row, callback, index, results, resultFuture) { @Override - Result adaptResponse(AnviltopServices.GetRowResponse response) { + Object adaptResponse(AnviltopServices.GetRowResponse response) { return getRowResponseAdapter.adaptResponse(response); } }, @@ -355,7 +355,7 @@ Result adaptResponse(AnviltopServices.GetRowResponse response) { new RpcResultFutureCallback( row, callback, index, results, resultFuture) { @Override - Result adaptResponse(AnviltopServices.IncrementRowResponse response) { + Object adaptResponse(AnviltopServices.IncrementRowResponse response) { return incrRespAdapter.adaptResponse(response); } }, @@ -367,7 +367,7 @@ Result adaptResponse(AnviltopServices.IncrementRowResponse response) { new RpcResultFutureCallback( row, callback, index, results, resultFuture) { @Override - Result adaptResponse(AnviltopServices.MutateRowResponse response) { + Object adaptResponse(AnviltopServices.MutateRowResponse response) { return new Result(); } }, @@ -379,7 +379,7 @@ Result adaptResponse(AnviltopServices.MutateRowResponse response) { new RpcResultFutureCallback( row, callback, index, results, resultFuture) { @Override - Result adaptResponse(AnviltopServices.MutateRowResponse response) { + Object adaptResponse(AnviltopServices.MutateRowResponse response) { return new Result(); } }, @@ -396,10 +396,10 @@ Result adaptResponse(AnviltopServices.MutateRowResponse response) { /** * Implementation of {@link org.apache.hadoop.hbase.client.HTable#batch(List, Object[])} */ - public void batch(List actions, @Nullable Result[] results) + public void batch(List actions, @Nullable Object[] results) throws IOException, InterruptedException { if (results == null) { - results = new Result[actions.size()]; + results = new Object[actions.size()]; } Preconditions.checkArgument(results.length == actions.size(), "Result array must have same dimensions as actions list."); @@ -436,7 +436,7 @@ public void batch(List actions, @Nullable Result[] results) /** * Implementation of {@link org.apache.hadoop.hbase.client.HTable#batch(List)} */ - public Result[] batch(List actions) throws IOException { + public Object[] batch(List actions) throws IOException { Result[] results = new Result[actions.size()]; try { batch(actions, results); @@ -472,7 +472,7 @@ public Result[] batchCallback( * {@link org.apache.hadoop.hbase.client.HTable#batchCallback(List, Object[], Batch.Callback)} */ public void batchCallback(List actions, - Result[] results, Batch.Callback callback) throws IOException, InterruptedException { + Object[] results, Batch.Callback callback) throws IOException, InterruptedException { Preconditions.checkArgument(results.length == actions.size(), "Result array must be the same length as actions."); int index = 0; @@ -494,7 +494,7 @@ public void batchCallback(List actions, */ public Boolean[] exists(List gets) throws IOException { // get(gets) will throw if there are any errors: - Result[] getResults = batch(gets); + Result[] getResults = (Result[]) batch(gets); Boolean[] exists = new Boolean[getResults.length]; for (int index = 0; index < getResults.length; index++) {