rubenada commented on code in PR #4204: URL: https://github.com/apache/calcite/pull/4204#discussion_r1966834933
########## core/src/main/java/org/apache/calcite/rel/rules/DphypJoinReorderRule.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.calcite.rel.rules; + +import org.apache.calcite.plan.RelOptRuleCall; +import org.apache.calcite.plan.RelRule; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.core.Join; +import org.apache.calcite.rex.RexBuilder; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.tools.RelBuilder; + +import org.immutables.value.Value; + +import java.util.ArrayList; +import java.util.List; + +/** Rule that re-orders a {@link Join} tree using dphyp algorithm. + * + * @see CoreRules#HYPER_GRAPH_OPTIMIZE */ [email protected] +public class DphypJoinReorderRule + extends RelRule<DphypJoinReorderRule.Config> + implements TransformationRule { + + protected DphypJoinReorderRule(Config config) { + super(config); + } + + @Override public void onMatch(RelOptRuleCall call) { + HyperGraph hyperGraph = call.rel(0); + RelBuilder relBuilder = call.builder(); + // make all field name unique and convert the + // HyperEdge condition from RexInputRef to RexInputFieldName + hyperGraph.convertHyperEdgeCond(); + + // enumerate by Dphyp + DpHyp dpHyp = new DpHyp(hyperGraph, relBuilder, call.getMetadataQuery()); + dpHyp.startEnumerateJoin(); + RelNode orderedJoin = dpHyp.getBestPlan(); + if (orderedJoin == null) { + return; Review Comment: If we get here, it means something went wrong, doesn't it? Or is this a valid scenario? -- 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]
