You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nd...@apache.org on 2020/06/25 18:17:46 UTC
[hbase] branch branch-2 updated: HBASE-22504 Addendum: restore
findCommonPrefix
This is an automated email from the ASF dual-hosted git repository.
ndimiduk pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2 by this push:
new 3db4f00 HBASE-22504 Addendum: restore findCommonPrefix
3db4f00 is described below
commit 3db4f00f24deccf781ae7ca11b7c5bc3e6409bed
Author: Nick Dimiduk <nd...@apache.org>
AuthorDate: Thu Jun 25 11:09:58 2020 -0700
HBASE-22504 Addendum: restore findCommonPrefix
Address incompatibility issue raised in 2.3.0RC0 vote thread.
---
.../apache/hadoop/hbase/util/ByteBufferUtils.java | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java
index e29ead5..ae87e32 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java
@@ -738,6 +738,28 @@ public final class ByteBufferUtils {
}
/**
+ * Find length of common prefix of two parts in the buffer
+ * @param buffer Where parts are located.
+ * @param offsetLeft Offset of the first part.
+ * @param offsetRight Offset of the second part.
+ * @param limit Maximal length of common prefix.
+ * @return Length of prefix.
+ */
+ @SuppressWarnings("unused")
+ public static int findCommonPrefix(ByteBuffer buffer, int offsetLeft,
+ int offsetRight, int limit) {
+ int prefix = 0;
+
+ for (; prefix < limit; ++prefix) {
+ if (buffer.get(offsetLeft + prefix) != buffer.get(offsetRight + prefix)) {
+ break;
+ }
+ }
+
+ return prefix;
+ }
+
+ /**
* Find length of common prefix in two arrays.
* @param left Array to be compared.
* @param leftOffset Offset in left array.