Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B474A200B70 for ; Sat, 23 Jul 2016 01:36:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B30D9160A8F; Fri, 22 Jul 2016 23:36:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DA111160A92 for ; Sat, 23 Jul 2016 01:36:26 +0200 (CEST) Received: (qmail 78148 invoked by uid 500); 22 Jul 2016 23:36:25 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 77936 invoked by uid 99); 22 Jul 2016 23:36:25 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Jul 2016 23:36:25 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 57974E0844; Fri, 22 Jul 2016 23:36:25 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mbertozzi@apache.org To: commits@hbase.apache.org Date: Fri, 22 Jul 2016 23:36:26 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/6] hbase git commit: HBASE-16272 Overflow in ServerName's compareTo method (Huaxiang Sun) archived-at: Fri, 22 Jul 2016 23:36:27 -0000 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/24a3d695 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/24a3d695 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/24a3d695 Branch: refs/heads/branch-1 Commit: 24a3d6952ccffdcb340f520926852af788d59ef1 Parents: ce651f5 Author: Matteo Bertozzi Authored: Fri Jul 22 15:28:04 2016 -0700 Committer: Matteo Bertozzi Committed: Fri Jul 22 15:29:19 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/24a3d695/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 4dc5a5a..c90e7e1 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 @@ -290,7 +290,8 @@ public class ServerName implements Comparable, 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/24a3d695/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 010559f..f95cf00 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 @@ -751,8 +751,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 @@ -989,13 +988,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/24a3d695/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 94db0d2..c0a9e17 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 @@ -1076,9 +1076,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); } }; @@ -1199,9 +1197,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 @@ -1348,13 +1344,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/24a3d695/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 181d96e..c7016e4 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 @@ -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); } } http://git-wip-us.apache.org/repos/asf/hbase/blob/24a3d695/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 59554cd..1721c20 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 @@ -3412,7 +3412,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()); } };