Skip to content

Commit ae5268f

Browse files
committed
Minor
1 parent ce22173 commit ae5268f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

core/src/main/java/org/apache/calcite/rel/rules/LoptOptimizeJoinRule.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import java.util.Map;
6161
import java.util.Set;
6262
import java.util.TreeSet;
63-
import java.util.function.BiFunction;
6463

6564
import static java.util.Objects.requireNonNull;
6665

@@ -955,10 +954,10 @@ private static boolean isJoinTree(RelNode rel) {
955954
RelOptCost costPushDown = null;
956955
RelOptCost costTop = null;
957956
if (pushDownTree != null) {
958-
costPushDown = config.costFunction().apply(call, pushDownTree.getJoinTree());
957+
costPushDown = config.costFunction().getCost(call, pushDownTree.getJoinTree());
959958
}
960959
if (topTree != null) {
961-
costTop = config.costFunction().apply(call, topTree.getJoinTree());
960+
costTop = config.costFunction().getCost(call, topTree.getJoinTree());
962961
}
963962

964963
if (pushDownTree == null) {
@@ -2083,20 +2082,25 @@ private static boolean areSelfJoinKeysUnique(RelMetadataQuery mq,
20832082
joinInfo.leftSet());
20842083
}
20852084

2085+
/** Function to compute cost. */
2086+
@FunctionalInterface
2087+
public interface CostFunction {
2088+
@Nullable RelOptCost getCost(RelOptRuleCall call, RelNode relNode);
2089+
}
2090+
20862091
/** Rule configuration. */
20872092
@Value.Immutable
20882093
public interface Config extends RelRule.Config {
20892094
Config DEFAULT = ImmutableLoptOptimizeJoinRule.Config.of()
20902095
.withOperandSupplier(b -> b.operand(MultiJoin.class).anyInputs());
20912096

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() {
20952099
return (call, rel) -> call.getMetadataQuery().getCumulativeCost(rel);
20962100
}
20972101

20982102
/** Sets {@link #costFunction()}. */
2099-
Config withCostFunction(BiFunction<RelOptRuleCall, RelNode, RelOptCost> function);
2103+
Config withCostFunction(CostFunction function);
21002104

21012105
@Override default LoptOptimizeJoinRule toRule() {
21022106
return new LoptOptimizeJoinRule(this);

0 commit comments

Comments
 (0)