You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Apache9 (via GitHub)" <gi...@apache.org> on 2023/08/13 09:50:12 UTC

[GitHub] [hbase] Apache9 commented on a diff in pull request #5347: HBASE-28012 Avoid CellUtil.cloneRow in BufferedEncodedSeeker

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


##########
hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java:
##########
@@ -954,25 +1033,55 @@ private int compareTypeBytes(Cell key, Cell right) {
       return 0;
     }
 
+    // These findCommonPrefix* methods rely on the fact that keyOnlyKv is the "right" cell argument

Review Comment:
   Is it possible to enforce the type of the right Cell? So later when someone changes the implementation of upper layer, we will know that we should also change the implementation of this method



##########
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java:
##########
@@ -778,6 +778,30 @@ public static int findCommonPrefix(ByteBuffer left, int leftOffset, int leftLeng
     return result;
   }
 
+  /**
+   * Find length of common prefix in two arrays.
+   * @param left        ByteBuffer to be compared.
+   * @param leftOffset  Offset in left ByteBuffer.
+   * @param leftLength  Length of left ByteBuffer.
+   * @param right       Array to be compared
+   * @param rightOffset Offset in right Array.
+   * @param rightLength Length of right Array.
+   */
+  public static int findCommonPrefix(ByteBuffer left, int leftOffset, int leftLength, byte[] right,
+    int rightOffset, int rightLength) {
+    int length = Math.min(leftLength, rightLength);
+    int result = 0;
+
+    while (

Review Comment:
   This could also be improved by comparing 8 bytes each time.
   
   You can see the code in ByteBufferUtils.compareToUnsafe.
   
   Anyway, can be a follow on issue.



-- 
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