private void infer(List<RexNode> predicates, Set<String> allExprsDigests, List<RexNode> inferedPredicates, List<RexNode> nonFieldsPredicates, boolean includeEqualityInference, ImmutableBitSet inferringFields) { for (RexNode r : predicates) { if (!includeEqualityInference && equalityPredicates.contains(r.toString())) { continue; } Iterable<Mapping> ms = mappings(r); if (ms.iterator().hasNext()) { for (Mapping m : ms) { RexNode tr = r.accept( new RexPermuteInputsShuttle(m, joinRel.getInput(0), joinRel.getInput(1))); if (inferringFields.contains(RelOptUtil.InputFinder.bits(tr)) && !allExprsDigests.contains(tr.toString()) && !isAlwaysTrue(tr)) { inferedPredicates.add(tr); allExprsDigests.add(tr.toString()); } } } else { if (!isAlwaysTrue(r)) { nonFieldsPredicates.add(r); } } } }
new RexPermuteInputsShuttle(bottomMapping, relA, relC).visitList(nonIntersecting, newBottomList); new RexPermuteInputsShuttle(bottomMapping, relA, relC).visitList(bottomNonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = RexUtil.composeConjunction(rexBuilder, newBottomList, false); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB).visitList(intersecting, newTopList); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB).visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList, false); @SuppressWarnings("SuspiciousNameCombination")
/** * Applies a mapping to an expression. */ public static RexNode apply(Mappings.TargetMapping mapping, RexNode node) { return node.accept(RexPermuteInputsShuttle.of(mapping)); }
@Override public RexNode visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { final String name = (String) ((RexLiteral) call.getOperands().get(1)).getValue2(); final int i = lookup(fields, name); if (i >= 0) { return RexInputRef.of(i, fields); } } return super.visitCall(call); }
/** * Creates a RexPermuteInputsShuttle. * * <p>The mapping provides at most one target for every source. If a source * has no targets and is referenced in the expression, * {@link org.apache.calcite.util.mapping.Mappings.TargetMapping#getTarget(int)} * will give an error. Otherwise the mapping gives a unique target. * * @param mapping Mapping * @param inputs Input relational expressions */ public RexPermuteInputsShuttle( Mappings.TargetMapping mapping, RelNode... inputs) { this(mapping, fields(inputs)); }
aCount, aCount + bCount, cCount); final List<RexNode> newBottomList = new ArrayList<>(); new RexPermuteInputsShuttle(bottomMapping, relA, relC) .visitList(nonIntersecting, newBottomList); new RexPermuteInputsShuttle(bottomMapping, relA, relC) .visitList(bottomNonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = aCount, aCount + bCount, cCount); final List<RexNode> newTopList = new ArrayList<>(); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB) .visitList(intersecting, newTopList); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB) .visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList);
/** * Applies a mapping to an expression. */ public static RexNode apply(Mappings.TargetMapping mapping, RexNode node) { return node.accept(RexPermuteInputsShuttle.of(mapping)); }
@Override public RexNode visitCall(RexCall call) { if (call.getOperator() == RexBuilder.GET_OPERATOR) { final String name = (String) ((RexLiteral) call.getOperands().get(1)).getValue2(); final int i = lookup(fields, name); if (i >= 0) { return RexInputRef.of(i, fields); } } return super.visitCall(call); }
/** * Creates a RexPermuteInputsShuttle. * * <p>The mapping provides at most one target for every source. If a source * has no targets and is referenced in the expression, * {@link org.apache.calcite.util.mapping.Mappings.TargetMapping#getTarget(int)} * will give an error. Otherwise the mapping gives a unique target. * * @param mapping Mapping * @param inputs Input relational expressions */ public RexPermuteInputsShuttle( Mappings.TargetMapping mapping, RelNode... inputs) { this(mapping, fields(inputs)); }
private void infer(List<RexNode> predicates, Set<String> allExprsDigests, List<RexNode> inferedPredicates, List<RexNode> nonFieldsPredicates, boolean includeEqualityInference, ImmutableBitSet inferringFields) { for (RexNode r : predicates) { if (!includeEqualityInference && equalityPredicates.contains(r.toString())) { continue; } Iterable<Mapping> ms = mappings(r); if (ms.iterator().hasNext()) { for (Mapping m : ms) { RexNode tr = r.accept( new RexPermuteInputsShuttle(m, joinRel.getInput(0), joinRel.getInput(1))); if (inferringFields.contains(RelOptUtil.InputFinder.bits(tr)) && !allExprsDigests.contains(tr.toString()) && !isAlwaysTrue(tr)) { inferedPredicates.add(tr); allExprsDigests.add(tr.toString()); } } } else { if (!isAlwaysTrue(r)) { nonFieldsPredicates.add(r); } } } }
0, aCount + bCount, cCount); final List<RexNode> newBottomList = new ArrayList<>(); new RexPermuteInputsShuttle(bottomMapping, relC, relB) .visitList(nonIntersecting, newBottomList); new RexPermuteInputsShuttle(bottomMapping, relC, relB) .visitList(bottomNonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = 0, aCount + bCount, cCount); final List<RexNode> newTopList = new ArrayList<>(); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relA) .visitList(intersecting, newTopList); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relA) .visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList);
/** * Applies a mapping to an iterable over expressions. */ public static Iterable<RexNode> apply(Mappings.TargetMapping mapping, Iterable<? extends RexNode> nodes) { final RexPermuteInputsShuttle shuttle = RexPermuteInputsShuttle.of(mapping); return Iterables.transform(nodes, e -> e.accept(shuttle)); }
0, nSysFields + nFieldsLeft, nFieldsRight); final RexPermuteInputsShuttle rightPermute = new RexPermuteInputsShuttle(rightMapping, joinRel); Mappings.TargetMapping leftMapping = Mappings.createShiftMapping( nSysFields + nFieldsLeft, 0, nSysFields, nFieldsLeft); final RexPermuteInputsShuttle leftPermute = new RexPermuteInputsShuttle(leftMapping, joinRel); final List<RexNode> leftInferredPredicates = new ArrayList<>(); final List<RexNode> rightInferredPredicates = new ArrayList<>();
0, aCount + bCount, cCount); final List<RexNode> newBottomList = new ArrayList<>(); new RexPermuteInputsShuttle(bottomMapping, relC, relB) .visitList(nonIntersecting, newBottomList); new RexPermuteInputsShuttle(bottomMapping, relC, relB) .visitList(bottomNonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = 0, aCount + bCount, cCount); final List<RexNode> newTopList = new ArrayList<>(); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relA) .visitList(intersecting, newTopList); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relA) .visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList);
/** * Applies a mapping to an iterable over expressions. */ public static Iterable<RexNode> apply(Mappings.TargetMapping mapping, Iterable<? extends RexNode> nodes) { final RexPermuteInputsShuttle shuttle = RexPermuteInputsShuttle.of(mapping); return Iterables.transform(nodes, e -> e.accept(shuttle)); }
nSysFields + nFieldsLeft, nSysFields, 0, nFieldsLeft); leftChildPredicates = lPreds.accept( new RexPermuteInputsShuttle(leftMapping, joinRel.getInput(0))); nSysFields + nFieldsLeft, 0, nFieldsRight); rightChildPredicates = rPreds.accept( new RexPermuteInputsShuttle(rightMapping, joinRel.getInput(1)));
aCount, aCount + bCount, cCount); final List<RexNode> newBottomList = new ArrayList<>(); new RexPermuteInputsShuttle(bottomMapping, relA, relC) .visitList(nonIntersecting, newBottomList); new RexPermuteInputsShuttle(bottomMapping, relA, relC) .visitList(bottomNonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = aCount, aCount + bCount, cCount); final List<RexNode> newTopList = new ArrayList<>(); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB) .visitList(intersecting, newTopList); new RexPermuteInputsShuttle(topMapping, newBottomJoin, relB) .visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList);
0, nSysFields + nFieldsLeft, nFieldsRight); final RexPermuteInputsShuttle rightPermute = new RexPermuteInputsShuttle(rightMapping, joinRel); Mappings.TargetMapping leftMapping = Mappings.createShiftMapping( nSysFields + nFieldsLeft, 0, nSysFields, nFieldsLeft); final RexPermuteInputsShuttle leftPermute = new RexPermuteInputsShuttle(leftMapping, joinRel); final List<RexNode> leftInferredPredicates = new ArrayList<>(); final List<RexNode> rightInferredPredicates = new ArrayList<>();
final Mappings.TargetMapping thruProjectMapping = Mappings.multiply(extendedProjectPerm, createAbstractTargetMapping(tempMapping)); final List<RexNode> newBottomList = new ArrayList<>(); new RexPermuteInputsShuttle(thruProjectMapping, relA, relC).visitList(nonIntersecting, newBottomList); final RexBuilder rexBuilder = cluster.getRexBuilder(); RexNode newBottomCondition = RexUtil.composeConjunction(rexBuilder, newBottomList, false); new RexPermuteInputsShuttle(thruProjectMapping, newBottomJoin, relB).visitList(intersecting, newTopList); new RexPermuteInputsShuttle(nonThruProjectMapping, newBottomJoin, relB).visitList(bottomIntersecting, newTopList); RexNode newTopCondition = RexUtil.composeConjunction(rexBuilder, newTopList, false); @SuppressWarnings("SuspiciousNameCombination")
nSysFields + nFieldsLeft, nSysFields, 0, nFieldsLeft); leftChildPredicates = lPreds.accept( new RexPermuteInputsShuttle(leftMapping, joinRel.getInput(0))); nSysFields + nFieldsLeft, 0, nFieldsRight); rightChildPredicates = rPreds.accept( new RexPermuteInputsShuttle(rightMapping, joinRel.getInput(1)));