gortiz commented on code in PR #13221: URL: https://github.com/apache/pinot/pull/13221#discussion_r1618802645
########## pinot-query-planner/src/main/java/org/apache/pinot/query/planner/serde/PlanNodeSerializationVisitor.java: ########## @@ -0,0 +1,386 @@ +/** + * 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.pinot.query.planner.serde; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import org.apache.calcite.rel.RelDistribution; +import org.apache.calcite.rel.RelFieldCollation; +import org.apache.calcite.rel.core.JoinRelType; +import org.apache.calcite.rel.logical.PinotRelExchangeType; +import org.apache.pinot.common.proto.Expressions; +import org.apache.pinot.common.proto.Plan; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.query.planner.logical.RexExpression; +import org.apache.pinot.query.planner.plannode.AbstractPlanNode; +import org.apache.pinot.query.planner.plannode.AggregateNode; +import org.apache.pinot.query.planner.plannode.ExchangeNode; +import org.apache.pinot.query.planner.plannode.FilterNode; +import org.apache.pinot.query.planner.plannode.JoinNode; +import org.apache.pinot.query.planner.plannode.MailboxReceiveNode; +import org.apache.pinot.query.planner.plannode.MailboxSendNode; +import org.apache.pinot.query.planner.plannode.PlanNodeVisitor; +import org.apache.pinot.query.planner.plannode.ProjectNode; +import org.apache.pinot.query.planner.plannode.SetOpNode; +import org.apache.pinot.query.planner.plannode.SortNode; +import org.apache.pinot.query.planner.plannode.TableScanNode; +import org.apache.pinot.query.planner.plannode.ValueNode; +import org.apache.pinot.query.planner.plannode.WindowNode; + + +public class PlanNodeSerializationVisitor implements PlanNodeVisitor<Void, Plan.StageNode.Builder> { + public static final PlanNodeSerializationVisitor INSTANCE = new PlanNodeSerializationVisitor(); + + private PlanNodeSerializationVisitor() { + } + + public Plan.StageNode process(AbstractPlanNode planNode) { + Plan.StageNode.Builder builder = Plan.StageNode.newBuilder().setStageId(planNode.getPlanFragmentId()); + DataSchema dataSchema = planNode.getDataSchema(); + for (int i = 0; i < dataSchema.getColumnNames().length; i++) { + builder.addColumnNames(dataSchema.getColumnName(i)); + builder.addColumnDataTypes(RexExpressionToProtoExpression.convertColumnDataType(dataSchema.getColumnDataType(i))); + } + + planNode.visit(this, builder); + planNode.getInputs().forEach(input -> builder.addInputs(process((AbstractPlanNode) input))); + + return builder.build(); + } + + @Override + public Void visitAggregate(AggregateNode node, Plan.StageNode.Builder builder) { + Plan.AggregateNode.Builder aggregateNodeBuilder = + Plan.AggregateNode.newBuilder().setNodeHint(getNodeHintBuilder(node.getNodeHint())) + .setAggCalls(convertExpressions(node.getAggCalls())).addAllFilterArgIndices(node.getFilterArgIndices()) + .setGroupSet(convertExpressions(node.getGroupSet())).setAggType(convertAggType(node.getAggType())); + + builder.setAggregateNode(aggregateNodeBuilder); + return null; + } + + @Override + public Void visitFilter(FilterNode node, Plan.StageNode.Builder builder) { + Expressions.RexExpression condition = RexExpressionToProtoExpression.process(node.getCondition()); + Plan.FilterNode.Builder filterNodeBuilder = Plan.FilterNode.newBuilder().setCondition(condition); + builder.setFilterNode(filterNodeBuilder); + + return null; + } + + @Override + public Void visitJoin(JoinNode node, Plan.StageNode.Builder builder) { + Plan.JoinKeys.Builder joinKeyBuilder = Plan.JoinKeys.newBuilder().addAllLeftKeys(node.getJoinKeys().getLeftKeys()) + .addAllRightKeys(node.getJoinKeys().getRightKeys()); + + Plan.JoinNode.Builder joinNodeBuilder = + Plan.JoinNode.newBuilder().setJoinRelType(convertJoinRelType(node.getJoinRelType())).setJoinKeys(joinKeyBuilder) + .setJoinClause(convertExpressions(node.getJoinClauses())) + .setJoinHints(getNodeHintBuilder(node.getJoinHints())).addAllLeftColumnNames(node.getLeftColumnNames()) + .addAllRightColumnNames(node.getRightColumnNames()); + + builder.setJoinNode(joinNodeBuilder); Review Comment: The intellij convention is not using the project code styles. Or being more precise, the project code style does not define this situation, so intellij is free to do whatever it does by default. TBH this is not even defined in Google style guide, which basically says to do whatever it considered better. The fact that Intellij just tries to add as many methods as possible in the same line is a cheap decision by their side. I would love that by default intellij would have decided to do not modify these lines given it there is no clear winner in 100% of the cases. So my suggestion is to disable that option in intellij code style, but again, this is not a strong policy we have in the project. -- 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-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org