hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [5/6] hbase git commit: HBASE-16272 Overflow in ServerName's compareTo method (Huaxiang Sun)
Date Fri, 22 Jul 2016 23:36:29 GMT
HBASE-16272 Overflow in ServerName's compareTo method (Huaxiang Sun)


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

Branch: refs/heads/branch-1.1
Commit: 4f6647b9f0d089341d4aa9e693e421b2c89ac514
Parents: bc824ee
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Fri Jul 22 15:28:04 2016 -0700
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Fri Jul 22 15:45:27 2016 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/hbase/ServerName.java  |  3 ++-
 .../apache/hadoop/hbase/io/hfile/LruBlockCache.java    |  7 +++----
 .../hadoop/hbase/io/hfile/bucket/BucketCache.java      | 13 +++++--------
 .../apache/hadoop/hbase/ipc/SimpleRpcScheduler.java    |  2 +-
 .../java/org/apache/hadoop/hbase/util/HBaseFsck.java   |  2 +-
 5 files changed, 12 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4f6647b9/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java
index e7fbefb..0509b95 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ServerName.java
@@ -288,7 +288,8 @@ public class ServerName implements Comparable<ServerName>, Serializable
{
     if (compare != 0) return compare;
     compare = this.getPort() - other.getPort();
     if (compare != 0) return compare;
-    return (int)(this.getStartcode() - other.getStartcode());
+
+    return Long.compare(this.getStartcode(), other.getStartcode());
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/4f6647b9/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
index 48e4cad..4e4474f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java
@@ -717,8 +717,7 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize {
     }
 
     public int compareTo(BlockBucket that) {
-      if(this.overflow() == that.overflow()) return 0;
-      return this.overflow() > that.overflow() ? 1 : -1;
+      return Long.compare(this.overflow(), that.overflow());
     }
 
     @Override
@@ -955,13 +954,13 @@ public class LruBlockCache implements ResizableBlockCache, HeapSize
{
           public int compareTo(CachedBlock other) {
             int diff = this.getFilename().compareTo(other.getFilename());
             if (diff != 0) return diff;
-            diff = (int)(this.getOffset() - other.getOffset());
+            diff = Long.compare(this.getOffset(), other.getOffset());
             if (diff != 0) return diff;
             if (other.getCachedTime() < 0 || this.getCachedTime() < 0) {
               throw new IllegalStateException("" + this.getCachedTime() + ", " +
                 other.getCachedTime());
             }
-            return (int)(other.getCachedTime() - this.getCachedTime());
+            return Long.compare(other.getCachedTime(), this.getCachedTime());
           }
 
           @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/4f6647b9/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index 45c75e3..54b9398 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -1088,9 +1088,7 @@ public class BucketCache implements BlockCache, HeapSize {
 
       @Override
       public int compare(BucketEntry o1, BucketEntry o2) {
-        long accessCounter1 = o1.accessCounter;
-        long accessCounter2 = o2.accessCounter;
-        return accessCounter1 < accessCounter2 ? 1 : accessCounter1 == accessCounter2
? 0 : -1;
+        return Long.compare(o2.accessCounter, o1.accessCounter);
       }
     };
 
@@ -1211,9 +1209,7 @@ public class BucketCache implements BlockCache, HeapSize {
 
     @Override
     public int compareTo(BucketEntryGroup that) {
-      if (this.overflow() == that.overflow())
-        return 0;
-      return this.overflow() > that.overflow() ? 1 : -1;
+      return Long.compare(this.overflow(), that.overflow());
     }
 
     @Override
@@ -1360,13 +1356,14 @@ public class BucketCache implements BlockCache, HeapSize {
           public int compareTo(CachedBlock other) {
             int diff = this.getFilename().compareTo(other.getFilename());
             if (diff != 0) return diff;
-            diff = (int)(this.getOffset() - other.getOffset());
+
+            diff = Long.compare(this.getOffset(), other.getOffset());
             if (diff != 0) return diff;
             if (other.getCachedTime() < 0 || this.getCachedTime() < 0) {
               throw new IllegalStateException("" + this.getCachedTime() + ", " +
                 other.getCachedTime());
             }
-            return (int)(other.getCachedTime() - this.getCachedTime());
+            return Long.compare(other.getCachedTime(), this.getCachedTime());
           }
 
           @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/4f6647b9/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java
index d8ae3ba..724d5b8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java
@@ -81,7 +81,7 @@ public class SimpleRpcScheduler extends RpcScheduler {
       long deadlineB = priority.getDeadline(callB.getHeader(), callB.param);
       deadlineA = callA.timestamp + Math.min(deadlineA, maxDelay);
       deadlineB = callB.timestamp + Math.min(deadlineB, maxDelay);
-      return (int)(deadlineA - deadlineB);
+      return Long.compare(deadlineA, deadlineB);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/4f6647b9/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 7962f99..b835d9e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -3371,7 +3371,7 @@ public class HBaseFsck extends Configured implements Closeable {
       final Comparator<Cell> comp = new Comparator<Cell>() {
         @Override
         public int compare(Cell k1, Cell k2) {
-          return (int)(k1.getTimestamp() - k2.getTimestamp());
+          return Long.compare(k1.getTimestamp(), k2.getTimestamp());
         }
       };
 


Mime
View raw message