Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix equals and hashcode issue #1856

Merged
merged 3 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ public boolean equals(Object obj) {
LinkNode<K, V> other = (LinkNode<K, V>) obj;
return this.key().equals(other.key());
}

public int hashCode() {
return this.key().hashCode();
}
}

private static final class LinkedQueueNonBigLock<K, V> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ public boolean equals(Object obj) {
if (this.columns().size() != other.columns().size()) {
return false;
}

for (Map.Entry<String, String> e : this.columns.entrySet()) {
String key = e.getKey();
String value = e.getValue();
Expand All @@ -371,4 +372,8 @@ public boolean equals(Object obj) {
}
return true;
}

public int hashCode() {
return this.id().hashCode() ^ this.columns().hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public boolean equals(Object obj) {
return ElementHelper.areEqual(this, obj);
}

public int hashCode() {
return ElementHelper.hashCode(this);
}

public HugeEdgeProperty<V> switchEdgeOwner() {
assert this.owner instanceof HugeEdge;
return new HugeEdgeProperty<V>(((HugeEdge) this.owner).switchOwner(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() ^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() ^
Expand Down