|
60 | 60 | import java.util.Map;
|
61 | 61 | import java.util.Set;
|
62 | 62 | import java.util.TreeSet;
|
63 |
| -import java.util.function.BiFunction; |
64 | 63 |
|
65 | 64 | import static java.util.Objects.requireNonNull;
|
66 | 65 |
|
@@ -955,10 +954,10 @@ private static boolean isJoinTree(RelNode rel) {
|
955 | 954 | RelOptCost costPushDown = null;
|
956 | 955 | RelOptCost costTop = null;
|
957 | 956 | if (pushDownTree != null) {
|
958 |
| - costPushDown = config.costFunction().apply(call, pushDownTree.getJoinTree()); |
| 957 | + costPushDown = config.costFunction().getCost(call, pushDownTree.getJoinTree()); |
959 | 958 | }
|
960 | 959 | if (topTree != null) {
|
961 |
| - costTop = config.costFunction().apply(call, topTree.getJoinTree()); |
| 960 | + costTop = config.costFunction().getCost(call, topTree.getJoinTree()); |
962 | 961 | }
|
963 | 962 |
|
964 | 963 | if (pushDownTree == null) {
|
@@ -2083,20 +2082,25 @@ private static boolean areSelfJoinKeysUnique(RelMetadataQuery mq,
|
2083 | 2082 | joinInfo.leftSet());
|
2084 | 2083 | }
|
2085 | 2084 |
|
| 2085 | + /** Function to compute cost. */ |
| 2086 | + @FunctionalInterface |
| 2087 | + public interface CostFunction { |
| 2088 | + @Nullable RelOptCost getCost(RelOptRuleCall call, RelNode relNode); |
| 2089 | + } |
| 2090 | + |
2086 | 2091 | /** Rule configuration. */
|
2087 | 2092 | @Value.Immutable
|
2088 | 2093 | public interface Config extends RelRule.Config {
|
2089 | 2094 | Config DEFAULT = ImmutableLoptOptimizeJoinRule.Config.of()
|
2090 | 2095 | .withOperandSupplier(b -> b.operand(MultiJoin.class).anyInputs());
|
2091 | 2096 |
|
2092 |
| - /** Method to calculate intermediate cost computations. */ |
2093 |
| - @SuppressWarnings("argument.type.incompatible") |
2094 |
| - @Value.Default default BiFunction<RelOptRuleCall, RelNode, RelOptCost> costFunction() { |
| 2097 | + /** Function to calculate intermediate cost computations. */ |
| 2098 | + @Value.Default default CostFunction costFunction() { |
2095 | 2099 | return (call, rel) -> call.getMetadataQuery().getCumulativeCost(rel);
|
2096 | 2100 | }
|
2097 | 2101 |
|
2098 | 2102 | /** Sets {@link #costFunction()}. */
|
2099 |
| - Config withCostFunction(BiFunction<RelOptRuleCall, RelNode, RelOptCost> function); |
| 2103 | + Config withCostFunction(CostFunction function); |
2100 | 2104 |
|
2101 | 2105 | @Override default LoptOptimizeJoinRule toRule() {
|
2102 | 2106 | return new LoptOptimizeJoinRule(this);
|
|
0 commit comments