diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/auth/RolePermission.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/auth/RolePermission.java index 4d52986a52..1c35b7e8fb 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/auth/RolePermission.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/auth/RolePermission.java @@ -135,6 +135,10 @@ public boolean equals(Object object) { return Objects.equals(this.roles, other.roles); } + public int hashCode() { + return Objects.hash(this.roles); + } + @Override public String toString() { return this.roles.toString(); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java index 0bfda706db..d4c55d4d26 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/cache/RamCache.java @@ -252,6 +252,10 @@ public boolean equals(Object obj) { LinkNode other = (LinkNode) obj; return this.key().equals(other.key()); } + + public int hashCode() { + return this.key().hashCode(); + } } private static final class LinkedQueueNonBigLock { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinaryBackendEntry.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinaryBackendEntry.java index e3126dbe89..b540296b83 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinaryBackendEntry.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/BinaryBackendEntry.java @@ -197,6 +197,10 @@ public boolean equals(Object obj) { return this.columns.containsAll(other.columns); } + public int hashCode() { + return this.id().hashCode() ^ this.columns.size(); + } + protected static final class BinaryId implements Id { private final byte[] bytes; diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/TextBackendEntry.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/TextBackendEntry.java index 8e764a29bf..8f313d93cf 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/TextBackendEntry.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/backend/serializer/TextBackendEntry.java @@ -358,6 +358,7 @@ public boolean equals(Object obj) { if (this.columns().size() != other.columns().size()) { return false; } + for (Map.Entry e : this.columns.entrySet()) { String key = e.getKey(); String value = e.getValue(); @@ -371,4 +372,8 @@ public boolean equals(Object obj) { } return true; } + + public int hashCode() { + return this.id().hashCode() ^ this.columns().hashCode(); + } } diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/structure/HugeEdgeProperty.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/structure/HugeEdgeProperty.java index 00c234b664..c19152bae8 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/structure/HugeEdgeProperty.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/structure/HugeEdgeProperty.java @@ -63,6 +63,10 @@ public boolean equals(Object obj) { return ElementHelper.areEqual(this, obj); } + public int hashCode() { + return ElementHelper.hashCode(this); + } + public HugeEdgeProperty switchEdgeOwner() { assert this.owner instanceof HugeEdge; return new HugeEdgeProperty(((HugeEdge) this.owner).switchOwner(), diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeCountStep.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeCountStep.java index c23a22c01d..d13cc17f2c 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeCountStep.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeCountStep.java @@ -46,6 +46,20 @@ public HugeCountStep(final Traversal.Admin traversal, this.originGraphStep = originGraphStep; } + public boolean equals(Object obj) { + if (!(obj instanceof HugeCountStep)) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + HugeCountStep other = (HugeCountStep) obj; + return Objects.equals(this.originGraphStep, + other.originGraphStep) && this.done == other.done; + } + @Override public int hashCode() { return Objects.hash(super.hashCode(), this.originGraphStep, this.done); diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeGraphStep.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeGraphStep.java index 41f5a0742f..6ec98aa439 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeGraphStep.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeGraphStep.java @@ -198,6 +198,21 @@ public Iterator lastTimeResults() { return this.lastTimeResults; } + public boolean equals(Object obj) { + if (!(obj instanceof HugeGraphStep)) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + HugeGraphStep other = (HugeGraphStep) obj; + return this.hasContainers.equals(other.hasContainers) && + this.queryInfo.equals(other.queryInfo) && + this.lastTimeResults.equals(other.lastTimeResults); + } + @Override public int hashCode() { return super.hashCode() ^ diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeVertexStep.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeVertexStep.java index 2468c1f406..17d5c645c0 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeVertexStep.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/traversal/optimize/HugeVertexStep.java @@ -231,6 +231,21 @@ public Iterator lastTimeResults() { return this.iterator; } + public boolean equals(Object obj) { + if (!(obj instanceof HugeVertexStep)) { + return false; + } + + if (!super.equals(obj)) { + return false; + } + + HugeVertexStep other = (HugeVertexStep) obj; + return this.hasContainers.equals(other.hasContainers) && + this.queryInfo.equals(other.queryInfo) && + this.iterator.equals(other.iterator); + } + @Override public int hashCode() { return super.hashCode() ^