[NO ISSUE][OTH] Add hashcode and equals function to ComputePartition
- user model changes: no
- storage format changes: no
- interface changes: no
Change-Id: If05b1e443c7fb49cd4a3bfef5646d4e468c99d04
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17859
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Tested-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/ComputePartition.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/ComputePartition.java
index 1d11c30..540eb69 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/ComputePartition.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/cluster/ComputePartition.java
@@ -18,6 +18,8 @@
*/
package org.apache.asterix.common.cluster;
+import java.util.Objects;
+
public class ComputePartition {
private final String nodeId;
private final int id;
@@ -34,4 +36,18 @@
public int getId() {
return id;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nodeId, id);
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (!(object instanceof ComputePartition)) {
+ return false;
+ }
+ ComputePartition target = (ComputePartition) object;
+ return Objects.equals(id, target.getId()) && Objects.equals(nodeId, target.getNodeId());
+ }
}