public void onMatch(RelOptRuleCall call) { final MultiJoin multiJoinRel = call.rel(0); final LoptMultiJoin multiJoin = new LoptMultiJoin(multiJoinRel); final RelMetadataQuery mq = call.getMetadataQuery(); findRemovableOuterJoins(mq, multiJoin); final RexBuilder rexBuilder = multiJoinRel.getCluster().getRexBuilder(); final LoptSemiJoinOptimizer semiJoinOpt = new LoptSemiJoinOptimizer(call.getMetadataQuery(), multiJoin, rexBuilder); // determine all possible semijoins semiJoinOpt.makePossibleSemiJoins(multiJoin); // select the optimal join filters for semijoin filtering by // iteratively calling chooseBestSemiJoin; chooseBestSemiJoin will // apply semijoins in sort order, based on the cost of scanning each // factor; as it selects semijoins to apply and iterates through the // loop, the cost of scanning a factor will decrease in accordance // with the semijoins selected int iterations = 0; do { if (!semiJoinOpt.chooseBestSemiJoin(multiJoin)) { break; } if (iterations++ > 10) { break; } } while (true); multiJoin.setFactorWeights(); findRemovableSelfJoins(mq, multiJoin); findBestOrderings(mq, call.builder(), multiJoin, semiJoinOpt, call); }
public void onMatch(RelOptRuleCall call) { final MultiJoin multiJoinRel = call.rel(0); final LoptMultiJoin multiJoin = new LoptMultiJoin(multiJoinRel); final RelMetadataQuery mq = call.getMetadataQuery(); findRemovableOuterJoins(mq, multiJoin); final RexBuilder rexBuilder = multiJoinRel.getCluster().getRexBuilder(); final LoptSemiJoinOptimizer semiJoinOpt = new LoptSemiJoinOptimizer(call.getMetadataQuery(), multiJoin, rexBuilder); // determine all possible semijoins semiJoinOpt.makePossibleSemiJoins(multiJoin); // select the optimal join filters for semijoin filtering by // iteratively calling chooseBestSemiJoin; chooseBestSemiJoin will // apply semijoins in sort order, based on the cost of scanning each // factor; as it selects semijoins to apply and iterates through the // loop, the cost of scanning a factor will decrease in accordance // with the semijoins selected int iterations = 0; do { if (!semiJoinOpt.chooseBestSemiJoin(multiJoin)) { break; } if (iterations++ > 10) { break; } } while (true); multiJoin.setFactorWeights(); findRemovableSelfJoins(mq, multiJoin); findBestOrderings(mq, call.builder(), multiJoin, semiJoinOpt, call); }