You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2019/08/20 22:04:09 UTC
[calcite] 03/06: [CALCITE-3167] Make equals and hashCode methods
final in AbstractRelNode,
and remove overriding methods in EnumerableTableScan (Jin Xing)
This is an automated email from the ASF dual-hosted git repository.
jhyde pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
commit 3f550c3f28d75d0f75b5815a22395dbecf992f03
Author: jinxing <ji...@gmail.com>
AuthorDate: Fri Jul 5 10:55:03 2019 +0800
[CALCITE-3167] Make equals and hashCode methods final in AbstractRelNode, and remove overriding methods in EnumerableTableScan (Jin Xing)
Close apache/calcite#1294
---
.../adapter/enumerable/EnumerableTableScan.java | 10 ----------
.../calcite/plan/RelOptMaterializations.java | 3 +++
.../org/apache/calcite/rel/AbstractRelNode.java | 22 ++++++++++++++++++++++
3 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
index 18dcee1..dfd7ac3 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
@@ -83,16 +83,6 @@ public class EnumerableTableScan
return new EnumerableTableScan(cluster, traitSet, relOptTable, elementType);
}
- @Override public boolean equals(Object obj) {
- return obj == this
- || obj instanceof EnumerableTableScan
- && table.equals(((EnumerableTableScan) obj).table);
- }
-
- @Override public int hashCode() {
- return table.hashCode();
- }
-
/** Returns whether EnumerableTableScan can generate code to handle a
* particular variant of the Table SPI. */
public static boolean canHandle(Table table) {
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java b/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
index e89b31f..2aa8afd 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptMaterializations.java
@@ -189,6 +189,9 @@ public abstract class RelOptMaterializations {
.addRuleInstance(ProjectRemoveRule.INSTANCE)
.build();
+ // We must use the same HEP planner for the two optimizations below.
+ // Thus different nodes with the same digest will share the same vertex in
+ // the plan graph. This is important for the matching process.
final HepPlanner hepPlanner = new HepPlanner(program);
hepPlanner.setRoot(target);
target = hepPlanner.findBestExp();
diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index f4899a1..d957ea2 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -390,6 +390,28 @@ public abstract class AbstractRelNode implements RelNode {
}
/**
+ * {@inheritDoc}
+ *
+ * <p>This method (and {@link #hashCode} is intentionally final. We do not want
+ * sub-classes of {@link RelNode} to redefine identity. Various algorithms
+ * (e.g. visitors, planner) can define the identity as meets their needs.
+ */
+ @Override public final boolean equals(Object obj) {
+ return super.equals(obj);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>This method (and {@link #equals} is intentionally final. We do not want
+ * sub-classes of {@link RelNode} to redefine identity. Various algorithms
+ * (e.g. visitors, planner) can define the identity as meets their needs.
+ */
+ @Override public final int hashCode() {
+ return super.hashCode();
+ }
+
+ /**
* A writer object used exclusively for computing the digest of a RelNode.
*
* <p>The writer is meant to be used only for computing a single digest and then thrown away.