Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenada committed Mar 8, 2025
1 parent ce22173 commit ae5268f
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.BiFunction;

import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -955,10 +954,10 @@ private static boolean isJoinTree(RelNode rel) {
RelOptCost costPushDown = null;
RelOptCost costTop = null;
if (pushDownTree != null) {
costPushDown = config.costFunction().apply(call, pushDownTree.getJoinTree());
costPushDown = config.costFunction().getCost(call, pushDownTree.getJoinTree());
}
if (topTree != null) {
costTop = config.costFunction().apply(call, topTree.getJoinTree());
costTop = config.costFunction().getCost(call, topTree.getJoinTree());
}

if (pushDownTree == null) {
Expand Down Expand Up @@ -2083,20 +2082,25 @@ private static boolean areSelfJoinKeysUnique(RelMetadataQuery mq,
joinInfo.leftSet());
}

/** Function to compute cost. */
@FunctionalInterface
public interface CostFunction {
@Nullable RelOptCost getCost(RelOptRuleCall call, RelNode relNode);
}

/** Rule configuration. */
@Value.Immutable
public interface Config extends RelRule.Config {
Config DEFAULT = ImmutableLoptOptimizeJoinRule.Config.of()
.withOperandSupplier(b -> b.operand(MultiJoin.class).anyInputs());

/** Method to calculate intermediate cost computations. */
@SuppressWarnings("argument.type.incompatible")
@Value.Default default BiFunction<RelOptRuleCall, RelNode, RelOptCost> costFunction() {
/** Function to calculate intermediate cost computations. */
@Value.Default default CostFunction costFunction() {
return (call, rel) -> call.getMetadataQuery().getCumulativeCost(rel);
}

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

@Override default LoptOptimizeJoinRule toRule() {
return new LoptOptimizeJoinRule(this);
Expand Down

0 comments on commit ae5268f

Please sign in to comment.