You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2018/02/01 21:21:44 UTC

hbase git commit: HBASE-19884 BucketEntryGroup's equals, hashCode and compareTo methods are not consistent

Repository: hbase
Updated Branches:
  refs/heads/branch-2 86ca65218 -> 7fe215db5


HBASE-19884 BucketEntryGroup's equals, hashCode and compareTo methods are not consistent

Move back to default equals and hashCode.
Remove compareTo and Comparator to PriorityQueue.

Signed-off-by: Michael Stack <st...@apache.org>


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

Branch: refs/heads/branch-2
Commit: 7fe215db5f01756307aabfa8648abdc298ed6f75
Parents: 86ca652
Author: Peter Somogyi <ps...@cloudera.com>
Authored: Tue Jan 30 10:14:08 2018 +0100
Committer: Michael Stack <st...@apache.org>
Committed: Thu Feb 1 13:21:23 2018 -0800

----------------------------------------------------------------------
 .../hbase/io/hfile/bucket/BucketCache.java      | 29 ++------------------
 1 file changed, 3 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/7fe215db/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 bd2b9c8..e9129d2 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
@@ -36,7 +36,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NavigableSet;
-import java.util.Objects;
 import java.util.PriorityQueue;
 import java.util.Set;
 import java.util.concurrent.ArrayBlockingQueue;
@@ -821,7 +820,8 @@ public class BucketCache implements BlockCache, HeapSize {
         }
       }
 
-      PriorityQueue<BucketEntryGroup> bucketQueue = new PriorityQueue<>(3);
+      PriorityQueue<BucketEntryGroup> bucketQueue = new PriorityQueue<>(3,
+          Comparator.comparingLong(BucketEntryGroup::overflow));
 
       bucketQueue.add(bucketSingle);
       bucketQueue.add(bucketMulti);
@@ -1350,7 +1350,7 @@ public class BucketCache implements BlockCache, HeapSize {
    * the eviction algorithm takes the appropriate number of elements out of each
    * according to configuration parameters and their relative sizes.
    */
-  private class BucketEntryGroup implements Comparable<BucketEntryGroup> {
+  private class BucketEntryGroup {
 
     private CachedEntryQueue queue;
     private long totalSize = 0;
@@ -1390,29 +1390,6 @@ public class BucketCache implements BlockCache, HeapSize {
     public long totalSize() {
       return totalSize;
     }
-
-    @Override
-    public int compareTo(BucketEntryGroup that) {
-      return Long.compare(this.overflow(), that.overflow());
-    }
-
-    @Override
-    public boolean equals(Object o) {
-      if (this == o) {
-        return true;
-      }
-      if (o == null || getClass() != o.getClass()) {
-        return false;
-      }
-      BucketEntryGroup that = (BucketEntryGroup) o;
-      return totalSize == that.totalSize && bucketSize == that.bucketSize
-          && Objects.equals(queue, that.queue);
-    }
-
-    @Override
-    public int hashCode() {
-      return Objects.hash(queue, totalSize, bucketSize);
-    }
   }
 
   /**