drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [1/8] drill git commit: DRILL-4359: Adds equals/hashCode methods to EndpointAffinity
Date Tue, 09 Feb 2016 00:26:52 GMT
Repository: drill
Updated Branches:
  refs/heads/master 83d460cfe -> ed2f1ca8e
Updated Tags:  refs/tags/0.5.0-incubating [created] f19015f2c
  refs/tags/archive/DRILL-2167 [created] cbfe5772d
  refs/tags/archive/DRILL-3450 [created] 2506ecf15
  refs/tags/drill-1.1.0 [created] 91a616f64
  refs/tags/drill-1.4.0 [created] 74b20027e
  refs/tags/drill-1.5.0 [created] 3158bebd8


DRILL-4359: Adds equals/hashCode methods to EndpointAffinity

Adds equals/hashCode methods to EndpointAffinity to allow for comparison in
tests.

This closes #363.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/6b1b4d25
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/6b1b4d25
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/6b1b4d25

Branch: refs/heads/master
Commit: 6b1b4d257b89e5579140e75388cd37db5563a6a8
Parents: 83d460c
Author: Laurent Goujon <laurent@dremio.com>
Authored: Fri Feb 5 14:06:00 2016 -0800
Committer: Jacques Nadeau <jacques@apache.org>
Committed: Sat Feb 6 18:33:12 2016 -0800

----------------------------------------------------------------------
 .../drill/exec/physical/EndpointAffinity.java   | 38 +++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/6b1b4d25/exec/java-exec/src/main/java/org/apache/drill/exec/physical/EndpointAffinity.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/EndpointAffinity.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/EndpointAffinity.java
index 4d8e23f..ce97a87 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/EndpointAffinity.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/EndpointAffinity.java
@@ -17,9 +17,9 @@
  */
 package org.apache.drill.exec.physical;
 
-import com.google.common.base.Preconditions;
 import org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint;
 
+import com.google.common.base.Preconditions;
 import com.google.protobuf.TextFormat;
 
 /**
@@ -96,6 +96,42 @@ public class EndpointAffinity {
   }
 
   @Override
+  public int hashCode() {
+    final int prime = 31;
+    int result = 1;
+    long temp;
+    temp = Double.doubleToLongBits(affinity);
+    result = prime * result + (int) (temp ^ (temp >>> 32));
+    result = prime * result + ((endpoint == null) ? 0 : endpoint.hashCode());
+    return result;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj) {
+      return true;
+    }
+    if (obj == null) {
+      return false;
+    }
+    if (!(obj instanceof EndpointAffinity)) {
+      return false;
+    }
+    EndpointAffinity other = (EndpointAffinity) obj;
+    if (Double.doubleToLongBits(affinity) != Double.doubleToLongBits(other.affinity)) {
+      return false;
+    }
+    if (endpoint == null) {
+      if (other.endpoint != null) {
+        return false;
+      }
+    } else if (!endpoint.equals(other.endpoint)) {
+      return false;
+    }
+    return true;
+  }
+
+  @Override
   public String toString() {
     return "EndpointAffinity [endpoint=" + TextFormat.shortDebugString(endpoint) + ", affinity="
+ affinity + "]";
   }


Mime
View raw message