Search in sources :

Example 1 with ReaderAllocations

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);
}
Also used : InputColumns(io.crate.execution.dsl.projection.builder.InputColumns) QueryThenFetch(io.crate.planner.node.dql.QueryThenFetch) Symbol(io.crate.expression.symbol.Symbol) ArrayList(java.util.ArrayList) FetchProjection(io.crate.execution.dsl.projection.FetchProjection) ReaderAllocations(io.crate.planner.ReaderAllocations) FetchPhase(io.crate.execution.dsl.phases.FetchPhase) DataType(io.crate.types.DataType)

Aggregations

FetchPhase (io.crate.execution.dsl.phases.FetchPhase)1 FetchProjection (io.crate.execution.dsl.projection.FetchProjection)1 InputColumns (io.crate.execution.dsl.projection.builder.InputColumns)1 Symbol (io.crate.expression.symbol.Symbol)1 ReaderAllocations (io.crate.planner.ReaderAllocations)1 QueryThenFetch (io.crate.planner.node.dql.QueryThenFetch)1 DataType (io.crate.types.DataType)1 ArrayList (java.util.ArrayList)1