This is an automated email from the ASF dual-hosted git repository. jakevin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 345eaab00b [refactor](Nereids): remove useless equals()/hashcode() about Id (#23162) 345eaab00b is described below commit 345eaab00be0b1b0651d5a9bf988e14f0308809f Author: jakevin <jakevin...@gmail.com> AuthorDate: Fri Aug 18 18:31:31 2023 +0800 [refactor](Nereids): remove useless equals()/hashcode() about Id (#23162) --- .../src/main/java/org/apache/doris/common/Id.java | 24 +++++++--------------- .../doris/nereids/trees/expressions/CTEId.java | 19 ----------------- .../doris/nereids/trees/expressions/ExprId.java | 19 ----------------- .../apache/doris/nereids/trees/plans/ObjectId.java | 19 ----------------- .../doris/nereids/trees/plans/RelationId.java | 19 ----------------- .../org/apache/doris/planner/RuntimeFilterId.java | 5 ----- 6 files changed, 7 insertions(+), 98 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/Id.java b/fe/fe-core/src/main/java/org/apache/doris/common/Id.java index 79372c52a0..9d6dad50a4 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/common/Id.java +++ b/fe/fe-core/src/main/java/org/apache/doris/common/Id.java @@ -26,37 +26,27 @@ import java.util.ArrayList; * Integer ids that cannot accidentally be compared with ints. */ public class Id<IdType extends Id<IdType>> { - private static final int INVALID_ID = -1; protected final int id; - public Id() { - this.id = INVALID_ID; - } - public Id(int id) { this.id = id; } - public boolean isValid() { - return id != INVALID_ID; - } - @Override public boolean equals(Object obj) { - if (obj == null) { - return false; + if (this == obj) { + return true; } - - // only ids of the same subclass are comparable - if (obj.getClass() != this.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } - return ((Id) obj).id == id; + Id<?> id1 = (Id<?>) obj; + return id == id1.id; } @Override public int hashCode() { - return Integer.valueOf(id).hashCode(); + return id; } public int asInt() { @@ -64,7 +54,7 @@ public class Id<IdType extends Id<IdType>> { } public ArrayList<IdType> asList() { - ArrayList<IdType> list = new ArrayList<IdType>(); + ArrayList<IdType> list = new ArrayList<>(); list.add((IdType) this); return list; } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CTEId.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CTEId.java index 823be79e4d..3fd714612f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CTEId.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/CTEId.java @@ -20,8 +20,6 @@ package org.apache.doris.nereids.trees.expressions; import org.apache.doris.common.Id; import org.apache.doris.common.IdGenerator; -import java.util.Objects; - /** * It is believed that use a specific definition for CTE could fascinatingly avoid careless codes and bugs. */ @@ -33,18 +31,6 @@ public class CTEId extends Id<CTEId> { super(id); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CTEId relationId = (CTEId) o; - return id == relationId.id; - } - /** * Should be only called by {@link StatementScopeIdGenerator}. */ @@ -57,11 +43,6 @@ public class CTEId extends Id<CTEId> { }; } - @Override - public int hashCode() { - return Objects.hash(id); - } - @Override public String toString() { return "CTEId#" + id; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ExprId.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ExprId.java index 0ea16ddf83..5e5a33fe49 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ExprId.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/ExprId.java @@ -20,8 +20,6 @@ package org.apache.doris.nereids.trees.expressions; import org.apache.doris.common.Id; import org.apache.doris.common.IdGenerator; -import java.util.Objects; - /** * UUID for Expression in Nereids. */ @@ -31,18 +29,6 @@ public class ExprId extends Id<ExprId> { super(id); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ExprId exprId = (ExprId) o; - return id == exprId.id; - } - /** * Should be only called by {@link StatementScopeIdGenerator}. */ @@ -55,11 +41,6 @@ public class ExprId extends Id<ExprId> { }; } - @Override - public int hashCode() { - return Objects.hash(id); - } - @Override public String toString() { return "" + id; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/ObjectId.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/ObjectId.java index c1f58361b3..1686ee257b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/ObjectId.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/ObjectId.java @@ -21,8 +21,6 @@ import org.apache.doris.common.Id; import org.apache.doris.common.IdGenerator; import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator; -import java.util.Objects; - /** * relation id */ @@ -32,18 +30,6 @@ public class ObjectId extends Id<ObjectId> { super(id); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ObjectId relationId = (ObjectId) o; - return id == relationId.id; - } - /** * Should be only called by {@link StatementScopeIdGenerator}. */ @@ -56,11 +42,6 @@ public class ObjectId extends Id<ObjectId> { }; } - @Override - public int hashCode() { - return Objects.hash(id); - } - @Override public String toString() { return "ObjectId#" + id; diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/RelationId.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/RelationId.java index 45e2ab7ee0..eb38c9a52d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/RelationId.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/RelationId.java @@ -21,8 +21,6 @@ import org.apache.doris.common.Id; import org.apache.doris.common.IdGenerator; import org.apache.doris.nereids.trees.expressions.StatementScopeIdGenerator; -import java.util.Objects; - /** * relation id */ @@ -32,18 +30,6 @@ public class RelationId extends Id<RelationId> { super(id); } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RelationId relationId = (RelationId) o; - return id == relationId.id; - } - /** * Should be only called by {@link StatementScopeIdGenerator}. */ @@ -56,11 +42,6 @@ public class RelationId extends Id<RelationId> { }; } - @Override - public int hashCode() { - return Objects.hash(id); - } - @Override public String toString() { return "RelationId#" + id; diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterId.java b/fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterId.java index 68fe2b636c..5af80375cd 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterId.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/RuntimeFilterId.java @@ -40,11 +40,6 @@ public class RuntimeFilterId extends Id<RuntimeFilterId> { return String.format("RF%03d", id); } - @Override - public int hashCode() { - return id; - } - public int compareTo(RuntimeFilterId cmp) { return Integer.compare(id, cmp.id); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org