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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to