use of io.crate.planner.PositionalOrderBy in project crate by crate.
the class Order method build.
@Override
public ExecutionPlan build(PlannerContext plannerContext, Set<PlanHint> planHints, ProjectionBuilder projectionBuilder, int limit, int offset, @Nullable OrderBy order, @Nullable Integer pageSizeHint, Row params, SubQueryResults subQueryResults) {
ExecutionPlan plan = source.build(plannerContext, planHints, projectionBuilder, limit, offset, orderBy, pageSizeHint, params, subQueryResults);
if (plan.resultDescription().orderBy() != null) {
// Collect applied ORDER BY eagerly to produce a optimized execution plan;
if (source instanceof Collect) {
return plan;
}
}
if (plan.resultDescription().hasRemainingLimitOrOffset()) {
plan = Merge.ensureOnHandler(plan, plannerContext);
}
InputColumns.SourceSymbols ctx = new InputColumns.SourceSymbols(source.outputs());
List<Symbol> orderByInputColumns = InputColumns.create(this.orderBy.orderBySymbols(), ctx);
ensureOrderByColumnsArePresentInOutputs(orderByInputColumns);
OrderedTopNProjection topNProjection = new OrderedTopNProjection(Limit.limitAndOffset(limit, offset), 0, InputColumns.create(outputs, ctx), orderByInputColumns, this.orderBy.reverseFlags(), this.orderBy.nullsFirst());
PositionalOrderBy positionalOrderBy = PositionalOrderBy.of(this.orderBy, outputs);
plan.addProjection(topNProjection, limit, offset, positionalOrderBy);
return plan;
}
Aggregations