From 85026d2a0f1a48a7207772e5a23d46c2275c97d1 Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Mon, 25 Jul 2022 17:27:49 -0700 Subject: [PATCH] Address review feedback --- .../hbase/coprocessor/example/RowCountEndpoint.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RowCountEndpoint.java b/hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RowCountEndpoint.java index df0c5d72aafc..40e16b79d27c 100644 --- a/hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RowCountEndpoint.java +++ b/hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RowCountEndpoint.java @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.List; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.mutable.MutableLong; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.CoprocessorEnvironment; @@ -36,6 +35,7 @@ import org.apache.hadoop.hbase.util.Bytes; import org.apache.yetus.audience.InterfaceAudience; +import org.apache.hbase.thirdparty.com.google.common.collect.Iterables; import org.apache.hbase.thirdparty.com.google.protobuf.RpcCallback; import org.apache.hbase.thirdparty.com.google.protobuf.RpcController; import org.apache.hbase.thirdparty.com.google.protobuf.Service; @@ -117,13 +117,13 @@ public void getKeyValueCount(RpcController controller, CountRequest request, scanner = env.getRegion().getScanner(new Scan()); List results = new ArrayList<>(); boolean hasMore = false; - MutableLong count = new MutableLong(); + long count = 0; do { hasMore = scanner.next(results); - results.forEach((r) -> count.increment()); + count += Iterables.size(results); results.clear(); } while (hasMore); - response = CountResponse.newBuilder().setCount(count.longValue()).build(); + response = CountResponse.newBuilder().setCount(count).build(); } catch (IOException ioe) { CoprocessorRpcUtils.setControllerException(controller, ioe); } finally {