You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2022/07/25 11:03:14 UTC

[GitHub] [hbase] Apache9 commented on a diff in pull request #4647: HBASE-27234 Clean up error-prone warnings in hbase-examples

Apache9 commented on code in PR #4647:
URL: https://github.com/apache/hbase/pull/4647#discussion_r928714152


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java:
##########
@@ -495,6 +494,21 @@ public static String toString(final byte[] b) {
     return toString(b, 0, b.length);
   }
 
+  /**
+   * Returns String made from <code>b</code>
+   */
+  public static String toString(ByteBuffer buf) {
+    if (buf == null) {
+      return null;
+    }
+    if (!buf.hasArray()) {
+      buf = ByteBuffer.wrap(buf.array(), buf.arrayOffset(), buf.remaining());

Review Comment:
   Copy paste error?



##########
hbase-examples/src/main/java/org/apache/hadoop/hbase/coprocessor/example/RowCountEndpoint.java:
##########
@@ -118,24 +117,18 @@ public void getKeyValueCount(RpcController controller, CountRequest request,
       scanner = env.getRegion().getScanner(new Scan());
       List<Cell> results = new ArrayList<>();
       boolean hasMore = false;
-      long count = 0;
+      MutableLong count = new MutableLong();
       do {
         hasMore = scanner.next(results);
-        for (Cell kv : results) {
-          count++;
-        }
+        results.forEach((r) -> count.increment());

Review Comment:
   Just use `count += result.size();` is enough?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org