use of io.crate.planner.ReaderAllocations in project crate by crate.
the class Fetch method build.
@Override
public ExecutionPlan build(PlannerContext plannerContext, Set<PlanHint> hints, ProjectionBuilder projectionBuilder, int limit, int offset, @Nullable OrderBy order, @Nullable Integer pageSizeHint, Row params, SubQueryResults subQueryResults) {
plannerContext.newReaderAllocations();
var executionPlan = Merge.ensureOnHandler(source.build(plannerContext, hints, projectionBuilder, limit, offset, order, pageSizeHint, params, subQueryResults), plannerContext);
ReaderAllocations readerAllocations = plannerContext.buildReaderAllocations();
Function<Symbol, Symbol> paramBinder = new SubQueryAndParamBinder(params, subQueryResults);
FetchPhase fetchPhase = new FetchPhase(plannerContext.nextExecutionPhaseId(), readerAllocations.nodeReaders().keySet(), readerAllocations.bases(), readerAllocations.tableIndices(), fetchRefs);
ArrayList<Symbol> boundOutputs = new ArrayList<>(replacedOutputs.size());
for (var entry : replacedOutputs.entrySet()) {
Symbol key = entry.getKey();
Symbol value = entry.getValue();
if (source.outputs().contains(key)) {
boundOutputs.add(paramBinder.apply(key));
} else {
boundOutputs.add(paramBinder.apply(value));
}
}
List<DataType<?>> inputTypes = Symbols.typeView(source.outputs());
List<Symbol> fetchOutputs = InputColumns.create(boundOutputs, new InputColumns.SourceSymbols(source.outputs()));
FetchProjection fetchProjection = new FetchProjection(fetchPhase.phaseId(), plannerContext.fetchSize(), fetchSourceByRelation, fetchOutputs, inputTypes, readerAllocations.nodeReaders(), readerAllocations.indices(), readerAllocations.indicesToIdents());
executionPlan.addProjection(fetchProjection);
return new QueryThenFetch(executionPlan, fetchPhase);
}
Aggregations