You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/05/08 08:53:57 UTC

[GitHub] [incubator-doris] EmmyMiao87 commented on a diff in pull request #9446: [Enhancement](Optimizer) Optimize nereids tree node structure

EmmyMiao87 commented on code in PR #9446:
URL: https://github.com/apache/incubator-doris/pull/9446#discussion_r867338822


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/AbstractTreeNode.java:
##########
@@ -0,0 +1,86 @@
+// 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.doris.nereids.trees;
+
+import com.google.common.collect.ImmutableList;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.nereids.trees.expressions.BinaryPredicate;
+import org.apache.doris.nereids.trees.expressions.SlotReference;
+import org.apache.doris.nereids.trees.plans.JoinType;
+import org.apache.doris.nereids.trees.plans.logical.LogicalJoin;
+import org.apache.doris.nereids.trees.plans.logical.LogicalRelation;
+import org.apache.doris.nereids.types.IntegerType;
+
+import java.util.List;
+
+/**
+ * Abstract class for plan node in Nereids, include plan node and expression.
+ *
+ * @param <NODE_TYPE> either {@link org.apache.doris.nereids.trees.plans.Plan}
+ *                 or {@link org.apache.doris.nereids.trees.expressions.Expression}
+ */
+public abstract class AbstractTreeNode<NODE_TYPE extends AbstractTreeNode<NODE_TYPE>>
+        implements TreeNode<NODE_TYPE> {
+
+    protected final NodeType type;
+    protected final List<TreeNode> children;
+
+    public AbstractTreeNode(NodeType type, TreeNode... children) {
+        this.type = type;
+        this.children = ImmutableList.copyOf(children);
+    }
+
+    public AbstractTreeNode(NodeType type, List<NODE_TYPE> children) {
+        this.type = type;
+        this.children = ImmutableList.copyOf(children);
+    }
+
+    @Override
+    public <CHILD_TYPE extends TreeNode<CHILD_TYPE>> List<CHILD_TYPE> children() {
+        return (List) children;
+    }
+
+    @Override
+    public <CHILD_TYPE extends TreeNode<CHILD_TYPE>> CHILD_TYPE child(int index) {
+        return (CHILD_TYPE) children.get(index);
+    }
+
+    public int arity() {
+        return children.size();
+    }
+
+    public static void main(String[] args) {

Review Comment:
   Remove this main function



-- 
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: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org