hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-20928 Rewrite calculation of midpoint in binarySearch functions to prevent overflow
Date Tue, 24 Jul 2018 15:16:39 GMT
Repository: hbase
Updated Branches:
  refs/heads/master a888af3dc -> 3a3855aad


HBASE-20928 Rewrite calculation of midpoint in binarySearch functions to prevent overflow

Signed-off-by: tedyu <yuzhihong@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/3a3855aa
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/3a3855aa
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/3a3855aa

Branch: refs/heads/master
Commit: 3a3855aade174d89087c5959320b7662347c1275
Parents: a888af3
Author: Saurabh Singh <saurabhsingh@csm-hadoop-spark-box.example.com>
Authored: Tue Jul 24 11:23:22 2018 +0530
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Jul 24 08:16:30 2018 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java  | 4 ++--
 .../src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java    | 2 +-
 .../src/main/java/org/apache/hadoop/hbase/util/Bytes.java      | 6 +++---
 .../java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java | 2 +-
 .../java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java | 2 +-
 .../apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java | 2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
index 1dd4e19..e1f00e2 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
@@ -126,10 +126,10 @@ public class RowIndexSeekerV1 extends AbstractEncodedSeeker {
   private int binarySearch(Cell seekCell, boolean seekBefore) {
     int low = 0;
     int high = rowNumber - 1;
-    int mid = (low + high) >>> 1;
+    int mid = low + ((high - low) >> 1);
     int comp = 0;
     while (low <= high) {
-      mid = (low + high) >>> 1;
+      mid = low + ((high - low) >> 1);
       ByteBuffer row = getRow(mid);
       comp = compareRows(row, seekCell);
       if (comp < 0) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
index 17b2a7c..68cf56e 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/nio/ByteBuff.java
@@ -527,7 +527,7 @@ public abstract class ByteBuff {
     int high = toIndex - 1;
 
     while (low <= high) {
-      int mid = (low + high) >>> 1;
+      int mid = low + ((high - low) >> 1);
       int midVal = a.get(mid) & 0xff;
 
       if (midVal < unsignedKey) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
index 15facea..12aaa67 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java
@@ -2029,7 +2029,7 @@ public class Bytes implements Comparable<Bytes> {
     int high = arr.length - 1;
 
     while (low <= high) {
-      int mid = (low + high) >>> 1;
+      int mid = low + ((high - low) >> 1);
       // we have to compare in this order, because the comparator order
       // has special logic when the 'left side' is a special key.
       int cmp = Bytes.BYTES_RAWCOMPARATOR
@@ -2104,7 +2104,7 @@ public class Bytes implements Comparable<Bytes> {
     int low = 0;
     int high = arr.length - 1;
     while (low <= high) {
-      int mid = (low+high) >>> 1;
+      int mid = low + ((high - low) >> 1);
       // we have to compare in this order, because the comparator order
       // has special logic when the 'left side' is a special key.
       int cmp = comparator.compare(key, arr[mid]);
@@ -2278,7 +2278,7 @@ public class Bytes implements Comparable<Bytes> {
     int high = toIndex - 1;
 
     while (low <= high) {
-      int mid = (low + high) >>> 1;
+      int mid = low + ((high - low) >> 1);
       int midVal = a[mid] & 0xff;
 
       if (midVal < unsignedKey) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
index d353bf8..b91b48c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileBlockIndex.java
@@ -745,7 +745,7 @@ public class HFileBlockIndex {
       ByteBufferKeyOnlyKeyValue nonRootIndexkeyOnlyKV = new ByteBufferKeyOnlyKeyValue();
       ObjectIntPair<ByteBuffer> pair = new ObjectIntPair<>();
       while (low <= high) {
-        mid = (low + high) >>> 1;
+        mid = low + ((high - low) >> 1);
 
         // Midkey's offset relative to the end of secondary index
         int midKeyRelOffset = nonRootIndex.getIntAfterPosition(Bytes.SIZEOF_INT * (mid +
1));

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java
index 17e64b0..ae48ea8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/CellFlatMap.java
@@ -83,7 +83,7 @@ public abstract class CellFlatMap implements NavigableMap<Cell,Cell>
{
     int end = maxCellIdx - 1;
 
     while (begin <= end) {
-      int mid = (begin + end) >>> 1;
+      int mid = begin + ((end - begin) >> 1);
       Cell midCell = getCell(mid);
       int compareRes = comparator.compare(midCell, needle);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/3a3855aa/hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java
index efad97e..3828606 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/BoundedPriorityBlockingQueue.java
@@ -119,7 +119,7 @@ public class BoundedPriorityBlockingQueue<E> extends AbstractQueue<E>
implements
 
     private int upperBound(int start, int end, E key) {
       while (start < end) {
-        int mid = (start + end) >>> 1;
+        int mid = start + ((end - start) >> 1);
         E mitem = objects[mid];
         int cmp = comparator.compare(mitem, key);
         if (cmp > 0) {


Mime
View raw message