From b96d60d6592a2d153a2978ae5ff961f52c85da05 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Sat, 19 Jan 2013 05:05:50 +0000 Subject: [PATCH] HBASE-7601 Fix 8 remaining EQ findbug warnings from hbase-server. git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1435487 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/client/Action.java | 10 +++++++++- .../java/org/apache/hadoop/hbase/client/Get.java | 13 +++++++++++++ .../org/apache/hadoop/hbase/client/Increment.java | 12 ++++++++++++ .../apache/hadoop/hbase/filter/NullComparator.java | 5 +++++ .../apache/hadoop/hbase/io/hfile/CachedBlock.java | 13 +++++++++++++ .../org/apache/hadoop/hbase/mapred/TableSplit.java | 13 +++++++++++++ .../org/apache/hadoop/hbase/master/RegionPlan.java | 12 ++++++++++++ .../regionserver/compactions/CompactionRequest.java | 5 +++++ 8 files changed, 82 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Action.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Action.java index 06475d04c19..1a5152fc428 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Action.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Action.java @@ -28,7 +28,7 @@ import org.apache.hadoop.classification.InterfaceStability; */ @InterfaceAudience.Public @InterfaceStability.Stable -public class Action implements Comparable { +public class Action implements Comparable { private Row action; private int originalIndex; @@ -77,4 +77,12 @@ public class Action implements Comparable { public int compareTo(Object o) { return action.compareTo(((Action) o).getAction()); } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Action other = (Action) obj; + return compareTo(other) == 0; + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Get.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Get.java index 0ade4e99996..ea7f0f72f3d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Get.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Get.java @@ -18,6 +18,7 @@ */ package org.apache.hadoop.hbase.client; + import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.hbase.HConstants; @@ -418,8 +419,20 @@ public class Get extends OperationWithAttributes } //Row + @Override public int compareTo(Row other) { return Bytes.compareTo(this.getRow(), other.getRow()); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + Row other = (Row) obj; + return compareTo(other) == 0; + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Increment.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Increment.java index 7df6e4bddda..85c0b213d08 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Increment.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/Increment.java @@ -274,4 +274,16 @@ public class Increment implements Row { public int compareTo(Row i) { return Bytes.compareTo(this.getRow(), i.getRow()); } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + Row other = (Row) obj; + return compareTo(other) == 0; + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/NullComparator.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/NullComparator.java index d944d3e444e..af27d60d4c7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/NullComparator.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/filter/NullComparator.java @@ -43,6 +43,11 @@ public class NullComparator extends ByteArrayComparable { return value != null ? 1 : 0; } + @Override + public boolean equals(Object obj) { + return obj == null; + } + @Override public int compareTo(byte[] value, int offset, int length) { throw new UnsupportedOperationException(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CachedBlock.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CachedBlock.java index 62e98c03de5..24350eed506 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CachedBlock.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/CachedBlock.java @@ -96,11 +96,24 @@ public class CachedBlock implements HeapSize, Comparable { return size; } + @Override public int compareTo(CachedBlock that) { if(this.accessTime == that.accessTime) return 0; return this.accessTime < that.accessTime ? 1 : -1; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + CachedBlock other = (CachedBlock) obj; + return compareTo(other) == 0; + } + public Cacheable getBuffer() { return this.buf; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java index 65082c8c000..3ae3b4cd4cc 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapred/TableSplit.java @@ -106,7 +106,20 @@ public class TableSplit implements InputSplit, Comparable { Bytes.toStringBinary(m_startRow) + "," + Bytes.toStringBinary(m_endRow); } + @Override public int compareTo(TableSplit o) { return Bytes.compareTo(getStartRow(), o.getStartRow()); } + + @Override + public boolean equals(Object o) { + if (o == null || !(o instanceof TableSplit)) { + return false; + } + TableSplit other = (TableSplit)o; + return Bytes.equals(m_tableName, other.m_tableName) && + Bytes.equals(m_startRow, other.m_startRow) && + Bytes.equals(m_endRow, other.m_endRow) && + m_regionLocation.equals(other.m_regionLocation); + } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlan.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlan.java index fc012f3052b..6fb3edfbbf0 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlan.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlan.java @@ -116,6 +116,18 @@ public class RegionPlan implements Comparable { return getRegionName().compareTo(o.getRegionName()); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + RegionPlan other = (RegionPlan) obj; + return compareTo(other) == 0; + } + @Override public String toString() { return "hri=" + this.hri.getRegionNameAsString() + ", src=" + diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java index 9017b02f636..78cad7f005d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/compactions/CompactionRequest.java @@ -174,6 +174,11 @@ public class CompactionRequest implements Comparable, return this.hashCode() - request.hashCode(); } + @Override + public boolean equals(Object obj) { + return (this == obj); + } + /** Gets the HRegion for the request */ public HRegion getHRegion() { return r;