diff --git hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java index 52db37b..12804df 100644 --- hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java +++ hbase-common/src/main/java/org/apache/hadoop/hbase/ServerName.java @@ -300,7 +300,8 @@ import org.apache.hadoop.hbase.util.Bytes; 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 diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java index c380318..567e515 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruBlockCache.java @@ -738,8 +738,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 @@ -976,13 +975,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 diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java index 6f0193f..dd4d517 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java @@ -1139,9 +1139,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); } }; @@ -1269,9 +1267,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 @@ -1418,13 +1414,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 diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java index 6e623a6..97c4430 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcScheduler.java @@ -143,7 +143,7 @@ public class SimpleRpcScheduler extends RpcScheduler implements ConfigurationObs 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); } } diff --git hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java index ea91d90..8e9134f 100644 --- hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java +++ hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java @@ -3390,7 +3390,7 @@ public class HBaseFsck extends Configured implements Closeable { final Comparator comp = new Comparator() { @Override public int compare(Cell k1, Cell k2) { - return (int)(k1.getTimestamp() - k2.getTimestamp()); + return Long.compare(k1.getTimestamp(), k2.getTimestamp()); } };