use of io.crate.execution.engine.distribution.SingleBucketBuilder in project crate by crate.
the class JobSetup method registerContextPhases.
private void registerContextPhases(Iterable<? extends NodeOperation> nodeOperations, Context context) {
for (NodeOperation nodeOperation : nodeOperations) {
// context for nodeOperations without dependencies can be built immediately (e.g. FetchPhase)
if (nodeOperation.downstreamExecutionPhaseId() == NodeOperation.NO_DOWNSTREAM) {
LOGGER.trace("Building context for nodeOp without downstream: {}", nodeOperation);
createContexts(nodeOperation.executionPhase(), context);
context.opCtx.builtNodeOperations.set(nodeOperation.executionPhase().phaseId());
}
if (ExecutionPhases.hasDirectResponseDownstream(nodeOperation.downstreamNodes())) {
var executionPhase = nodeOperation.executionPhase();
CircuitBreaker breaker = breaker();
int ramAccountingBlockSizeInBytes = BlockBasedRamAccounting.blockSizeInBytes(breaker.getLimit());
var ramAccounting = new BlockBasedRamAccounting(b -> breaker.addEstimateBytesAndMaybeBreak(b, executionPhase.label()), ramAccountingBlockSizeInBytes);
Streamer<?>[] streamers = StreamerVisitor.streamersFromOutputs(executionPhase);
SingleBucketBuilder bucketBuilder = new SingleBucketBuilder(streamers, ramAccounting);
context.directResponseFutures.add(bucketBuilder.completionFuture().whenComplete((res, err) -> ramAccounting.close()));
context.registerBatchConsumer(nodeOperation.downstreamExecutionPhaseId(), bucketBuilder);
}
}
}
Aggregations