@Override public RelNode convert(RelNode rel) { final Window window = (Window) rel; final RelTraitSet traitSet = window.getTraitSet().replace(OLAPRel.CONVENTION); final RelNode input = window.getInput(); return new OLAPWindowRel(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)), window.constants, window.getRowType(), window.groups); } }
public ImmutableList<RelCollation> collations(Window rel, RelMetadataQuery mq) { return ImmutableList.copyOf(window(mq, rel.getInput(), rel.groups)); }
public ImmutableList<RelCollation> collations(Window rel, RelMetadataQuery mq) { return ImmutableList.copyOf(window(mq, rel.getInput(), rel.groups)); }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { // Cost is proportional to the number of rows and the number of // components (groups and aggregate functions). There is // no I/O cost. // // TODO #1. Add memory cost. // TODO #2. MIN and MAX have higher CPU cost than SUM and COUNT. final double rowsIn = mq.getRowCount(getInput()); int count = groups.size(); for (Group group : groups) { count += group.aggCalls.size(); } return planner.getCostFactory().makeCost(rowsIn, rowsIn * count, 0); }
@Override public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery mq) { // Cost is proportional to the number of rows and the number of // components (groups and aggregate functions). There is // no I/O cost. // // TODO #1. Add memory cost. // TODO #2. MIN and MAX have higher CPU cost than SUM and COUNT. final double rowsIn = mq.getRowCount(getInput()); int count = groups.size(); for (Group group : groups) { count += group.aggCalls.size(); } return planner.getCostFactory().makeCost(rowsIn, rowsIn * count, 0); }
/** * Presents a view of the {@link RexWinAggCall} list as a list of * {@link AggregateCall}. */ public List<AggregateCall> getAggregateCalls(Window windowRel) { final List<String> fieldNames = Util.skip(windowRel.getRowType().getFieldNames(), windowRel.getInput().getRowType().getFieldCount()); return new AbstractList<AggregateCall>() { public int size() { return aggCalls.size(); } public AggregateCall get(int index) { final RexWinAggCall aggCall = aggCalls.get(index); final SqlAggFunction op = (SqlAggFunction) aggCall.getOperator(); return AggregateCall.create(op, aggCall.distinct, false, getProjectOrdinals(aggCall.getOperands()), -1, aggCall.getType(), fieldNames.get(aggCall.ordinal)); } }; } }
/** * Presents a view of the {@link RexWinAggCall} list as a list of * {@link AggregateCall}. */ public List<AggregateCall> getAggregateCalls(Window windowRel) { final List<String> fieldNames = Util.skip(windowRel.getRowType().getFieldNames(), windowRel.getInput().getRowType().getFieldCount()); return new AbstractList<AggregateCall>() { public int size() { return aggCalls.size(); } public AggregateCall get(int index) { final RexWinAggCall aggCall = aggCalls.get(index); final SqlAggFunction op = (SqlAggFunction) aggCall.getOperator(); return AggregateCall.create(op, aggCall.distinct, false, getProjectOrdinals(aggCall.getOperands()), -1, RelCollations.EMPTY, aggCall.getType(), fieldNames.get(aggCall.ordinal)); } }; } }
final RelDataType childRowType = getInput().getRowType();
final RelDataType childRowType = getInput().getRowType();
@Override public RelNode convert(RelNode rel) { final Window window = (Window) rel; final RelTraitSet traitSet = window.getTraitSet().replace(OLAPRel.CONVENTION); final RelNode input = window.getInput(); return new OLAPWindowRel(rel.getCluster(), traitSet, convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION)), window.constants, window.getRowType(), window.groups); } }
final MutableRel input = toMutable(window.getInput()); return MutableWindow.of(window.getRowType(), input, window.groups, window.getConstants());
final MutableRel input = toMutable(window.getInput()); return MutableWindow.of(window.getRowType(), input, window.groups, window.getConstants());