/** * Constructs a CalcRelSplitter. * * @param calc CalcRel to split * @param relTypes Array of rel types, e.g. {Java, Fennel}. Must be * distinct. */ CalcRelSplitter(CalcRelBase calc, RelType[] relTypes) { for (int i = 0; i < relTypes.length; i++) { assert relTypes[i] != null; for (int j = 0; j < i; j++) { assert relTypes[i] != relTypes[j] : "Rel types must be distinct"; } } this.program = calc.getProgram(); this.cluster = calc.getCluster(); this.traits = calc.getTraitSet(); this.typeFactory = calc.getCluster().getTypeFactory(); this.child = calc.getChild(); this.relTypes = relTypes; }
protected CalcRelBase( RelOptCluster cluster, RelTraitSet traits, RelNode child, RelDataType rowType, RexProgram program, List<RelCollation> collationList) { super(cluster, traits, child); this.rowType = rowType; this.program = program; this.collationList = ImmutableList.copyOf(collationList); assert isValid(true); }
@Override public RelOptCost computeSelfCost( RelOptPlanner planner ) { return super.computeSelfCost( planner ).multiplyBy( .1 ); }
/** * Creates a copy of this {@code CalcRelBase}. */ public abstract CalcRelBase copy( RelTraitSet traitSet, RelNode child, RexProgram program, List<RelCollation> collationList);
RexProgram topProgram = topCalc.getProgram(); if (RexOver.containsOver(topProgram)) { return; topCalc.getProgram(), bottomCalc.getProgram(), topCalc.getCluster().getRexBuilder()); assert mergedProgram.getOutputRowType() == topProgram.getOutputRowType(); final CalcRelBase newCalc = topCalc.copy( topCalc.getTraitSet(), bottomCalc.getChild(), mergedProgram, topCalc.getCollationList()); if (newCalc.getDigest().equals(bottomCalc.getDigest())) {
program.getInputRowType(), "child's output type", getChild().getRowType(), fail)) { return false; return false; if (!program.isNormalized(fail, getCluster().getRexBuilder())) { return false; getRowType(), collationList, fail)) {
public double getRows() { return FilterRel.estimateFilteredRows( getChild(), program); }
@Override public boolean matches(RelNode rel) { return super.matches(rel) && RexOver.containsOver(((CalcRelBase) rel).getProgram()); } },
program.getInputRowType(), "child's output type", getChild().getRowType(), fail)) return false; if (!program.isNormalized(fail, getCluster().getRexBuilder())) { return false; getRowType(), collationList, fail))
public double getRows() { return FilterRel.estimateFilteredRows( getChild(), program); }
public void onMatch(RelOptRuleCall call) { CalcRelBase calc = call.rel(0); assert RexOver.containsOver(calc.getProgram()); CalcRelSplitter transform = new WindowedAggRelSplitter(calc); RelNode newRel = transform.execute(); call.transformTo(newRel); } };
public RelOptCost computeSelfCost(RelOptPlanner planner) { double dRows = RelMetadataQuery.getRowCount(this); double dCpu = RelMetadataQuery.getRowCount(getChild()) * program.getExprCount(); double dIo = 0; return planner.makeCost(dRows, dCpu, dIo); }
protected CalcRelBase( RelOptCluster cluster, RelTraitSet traits, RelNode child, RelDataType rowType, RexProgram program, List<RelCollation> collationList) { super(cluster, traits, child); this.rowType = rowType; this.program = program; this.collationList = collationList.isEmpty() ? Collections.<RelCollation>emptyList() : collationList; assert isValid(true); }
public RelOptCost computeSelfCost(RelOptPlanner planner) { double dRows = RelMetadataQuery.getRowCount(this); double dCpu = RelMetadataQuery.getRowCount(getChild()) * program.getExprCount(); double dIo = 0; return planner.getCostFactory().makeCost(dRows, dCpu, dIo); }