zabetak commented on code in PR #4492:
URL: https://github.com/apache/calcite/pull/4492#discussion_r2260377589


##########
core/src/main/java/org/apache/calcite/plan/CommonRelExpressionRegistry.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.calcite.plan;
+
+import org.apache.calcite.rel.RelNode;
+
+import org.apiguardian.api.API;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.stream.Stream;
+
+/**
+ * A registry of common relational expressions for a given query.
+ *
+ * <p>The registry is only meant to hold common expressions for a single query.
+ *
+ * <p>The class is not thread-safe.
+ */
+@API(since = "1.41.0", status = API.Status.INTERNAL)
+public final class CommonRelExpressionRegistry {
+  /**
+   * A unique collection of common expressions.
+   *
+   * <p>The expressions may contain internal planning concepts such as {@link 
org.apache.calcite.plan.hep.HepRelVertex}.
+   */
+  private final Map<String, RelNode> rels = new HashMap<>();
+
+  /**
+   * Adds the specified expression to this registry.
+   *
+   * @param rel a relational expression to be added to the registry.
+   */
+  public void add(RelNode rel) {
+    this.rels.put(rel.getDigest(), rel);

Review Comment:
   The class is not meant to become a widely used API and that is why I marked 
it as internal. It works in a limited scope and very specific context.
   
   Nevertheless, in all places inside Calcite we use `getRelDigest` instead of 
`getDigest` to check for equivalence so it makes sense to use it here as well. 
   
   I applied your suggestion in 
https://github.com/apache/calcite/pull/4492/commits/3f0e885feb836ba73c444c6f96efc5ffc21c0fbf



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to