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


##########
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:
   Nice catch! Seems like it's a bit out of the scope of this PR like you 
mentioned. I'll create a follow up JIRA for optimizing the 
`ByteBufferUtils.findCommonPrefix` methods to compare 8 bytes at a time 
(instead of just a single byte at a time). 



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