/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param factRel fact table participating in the semijoin * @param dimRel dimension table participating in the semijoin * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, RelNode factRel, RelNode dimRel, SemiJoin rel) { return computeSemiJoinSelectivity(mq, factRel, dimRel, rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param factRel fact table participating in the semijoin * @param dimRel dimension table participating in the semijoin * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, RelNode factRel, RelNode dimRel, SemiJoin rel) { return computeSemiJoinSelectivity(mq, factRel, dimRel, rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, SemiJoin rel) { return computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel.getLeftKeys(), rel.getRightKeys()); }
/** * Computes the selectivity of a semijoin filter if it is applied on a fact * table. The computation is based on the selectivity of the dimension * table/columns and the number of distinct values in the fact table * columns. * * @param rel semijoin rel * @return calculated selectivity */ public static double computeSemiJoinSelectivity(RelMetadataQuery mq, SemiJoin rel) { return computeSemiJoinSelectivity(mq, rel.getLeft(), rel.getRight(), rel.getLeftKeys(), rel.getRightKeys()); }
chosenSemiJoins[bestDimIdx], semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys()); chosenSemiJoins[factIdx] = chosenSemiJoin;
chosenSemiJoins[bestDimIdx], semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys()); chosenSemiJoins[factIdx] = chosenSemiJoin;
public void onMatch(RelOptRuleCall call) { SemiJoin semiJoin = call.rel(0); LogicalProject project = call.rel(1); // Convert the LHS semi-join keys to reference the child projection // expression; all projection expressions must be RexInputRefs, // otherwise, we wouldn't have created this semi-join. final List<Integer> newLeftKeys = new ArrayList<>(); final List<Integer> leftKeys = semiJoin.getLeftKeys(); final List<RexNode> projExprs = project.getProjects(); for (int leftKey : leftKeys) { RexInputRef inputRef = (RexInputRef) projExprs.get(leftKey); newLeftKeys.add(inputRef.getIndex()); } // convert the semijoin condition to reflect the LHS with the project // pulled up RexNode newCondition = adjustCondition(project, semiJoin); SemiJoin newSemiJoin = SemiJoin.create(project.getInput(), semiJoin.getRight(), newCondition, ImmutableIntList.copyOf(newLeftKeys), semiJoin.getRightKeys()); // Create the new projection. Note that the projection expressions // are the same as the original because they only reference the LHS // of the semijoin and the semijoin only projects out the LHS final RelBuilder relBuilder = call.builder(); relBuilder.push(newSemiJoin); relBuilder.project(projExprs, project.getRowType().getFieldNames()); call.transformTo(relBuilder.build()); }
public void onMatch(RelOptRuleCall call) { SemiJoin semiJoin = call.rel(0); LogicalProject project = call.rel(1); // Convert the LHS semi-join keys to reference the child projection // expression; all projection expressions must be RexInputRefs, // otherwise, we wouldn't have created this semi-join. final List<Integer> newLeftKeys = new ArrayList<>(); final List<Integer> leftKeys = semiJoin.getLeftKeys(); final List<RexNode> projExprs = project.getProjects(); for (int leftKey : leftKeys) { RexInputRef inputRef = (RexInputRef) projExprs.get(leftKey); newLeftKeys.add(inputRef.getIndex()); } // convert the semijoin condition to reflect the LHS with the project // pulled up RexNode newCondition = adjustCondition(project, semiJoin); SemiJoin newSemiJoin = SemiJoin.create(project.getInput(), semiJoin.getRight(), newCondition, ImmutableIntList.copyOf(newLeftKeys), semiJoin.getRightKeys()); // Create the new projection. Note that the projection expressions // are the same as the original because they only reference the LHS // of the semijoin and the semijoin only projects out the LHS final RelBuilder relBuilder = call.builder(); relBuilder.push(newSemiJoin); relBuilder.project(projExprs, project.getRowType().getFieldNames()); call.transformTo(relBuilder.build()); }
public void onMatch(RelOptRuleCall call) { SemiJoin semiJoin = call.rel(0); LogicalFilter filter = call.rel(1); RelNode newSemiJoin = SemiJoin.create(filter.getInput(), semiJoin.getRight(), semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys()); final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY; RelNode newFilter = factory.createFilter(newSemiJoin, filter.getCondition()); call.transformTo(newFilter); } }
public void onMatch(RelOptRuleCall call) { SemiJoin semiJoin = call.rel(0); LogicalFilter filter = call.rel(1); RelNode newSemiJoin = SemiJoin.create(filter.getInput(), semiJoin.getRight(), semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys()); final RelFactories.FilterFactory factory = RelFactories.DEFAULT_FILTER_FACTORY; RelNode newFilter = factory.createFilter(newSemiJoin, filter.getCondition()); call.transformTo(newFilter); } }
public void onMatch(RelOptRuleCall call) { SemiJoin semiJoin = call.rel(0); LogicalProject project = call.rel(1); // Convert the LHS semi-join keys to reference the child projection // expression; all projection expressions must be RexInputRefs, // otherwise, we wouldn't have created this semi-join. final List<Integer> newLeftKeys = new ArrayList<>(); final List<Integer> leftKeys = semiJoin.getLeftKeys(); final List<RexNode> projExprs = project.getProjects(); for (int leftKey : leftKeys) { RexInputRef inputRef = (RexInputRef) projExprs.get(leftKey); newLeftKeys.add(inputRef.getIndex()); } // convert the semijoin condition to reflect the LHS with the project // pulled up RexNode newCondition = adjustCondition(project, semiJoin); SemiJoin newSemiJoin = SemiJoin.create(project.getInput(), semiJoin.getRight(), newCondition, ImmutableIntList.copyOf(newLeftKeys), semiJoin.getRightKeys(), semiJoin.isAnti); // Create the new projection. Note that the projection expressions // are the same as the original because they only reference the LHS // of the semijoin and the semijoin only projects out the LHS final RelBuilder relBuilder = call.builder(); relBuilder.push(newSemiJoin); relBuilder.project(projExprs, project.getRowType().getFieldNames()); call.transformTo(relBuilder.build()); }
SemiJoin semiJoin = multiJoin.getJoinRemovalSemiJoin(dimIdx); ImmutableIntList dimKeys = semiJoin.getRightKeys(); ImmutableIntList factKeys = semiJoin.getLeftKeys(); for (int i = 0; i < dimKeys.size(); i++) { replacementKeys[dimKeys.get(i)] = factKeys.get(i) + adjustment;
SemiJoin semiJoin = multiJoin.getJoinRemovalSemiJoin(dimIdx); ImmutableIntList dimKeys = semiJoin.getRightKeys(); ImmutableIntList factKeys = semiJoin.getLeftKeys(); for (int i = 0; i < dimKeys.size(); i++) { replacementKeys[dimKeys.get(i)] = factKeys.get(i) + adjustment;
return; final ImmutableIntList leftKeys = semiJoin.getLeftKeys(); final ImmutableIntList rightKeys = semiJoin.getRightKeys();
return; final ImmutableIntList leftKeys = semiJoin.getLeftKeys(); final ImmutableIntList rightKeys = semiJoin.getRightKeys();
final ImmutableIntList leftKeys = semiJoin.getLeftKeys(); final ImmutableIntList rightKeys = semiJoin.getRightKeys();
for (Integer key : semiJoin.getLeftKeys()) { factJoinRefCounts[key]--;
for (Integer key : semiJoin.getLeftKeys()) { factJoinRefCounts[key]--;
final MutableRel right = toMutable(semiJoin.getRight()); return MutableSemiJoin.of(semiJoin.getRowType(), left, right, semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys());
final MutableRel right = toMutable(semiJoin.getRight()); return MutableSemiJoin.of(semiJoin.getRowType(), left, right, semiJoin.getCondition(), semiJoin.getLeftKeys(), semiJoin.getRightKeys());