use of io.crate.execution.dsl.phases.ExecutionPhase in project crate by crate.
the class NodeOperationCtxTest method testIsUpstreamOnSameNodeWithTwoUpstreamsThatAreOnTheSameNode.
@Test
public void testIsUpstreamOnSameNodeWithTwoUpstreamsThatAreOnTheSameNode() {
ExecutionPhase p1 = StubPhases.newUpstreamPhase(0, DistributionInfo.DEFAULT_SAME_NODE, "n2");
ExecutionPhase p2 = StubPhases.newUpstreamPhase(2, DistributionInfo.DEFAULT_SAME_NODE, "n2");
ExecutionPhase p3 = newPhase(3, "n2");
NodeOperationCtx opCtx = new NodeOperationCtx("n1", List.of(NodeOperation.withDownstream(p1, p3, (byte) 0), NodeOperation.withDownstream(p2, p3, (byte) 0)));
assertThat(opCtx.upstreamsAreOnSameNode(3), is(true));
}
use of io.crate.execution.dsl.phases.ExecutionPhase in project crate by crate.
the class JobSetup method prepareOnHandler.
public List<CompletableFuture<StreamBucket>> prepareOnHandler(SessionSettings sessionInfo, Collection<? extends NodeOperation> nodeOperations, RootTask.Builder taskBuilder, List<Tuple<ExecutionPhase, RowConsumer>> handlerPhases, SharedShardContexts sharedShardContexts) {
Context context = new Context(clusterService.localNode().getId(), sessionInfo, taskBuilder, LOGGER, distributingConsumerFactory, nodeOperations, sharedShardContexts);
for (Tuple<ExecutionPhase, RowConsumer> handlerPhase : handlerPhases) {
context.registerLeaf(handlerPhase.v1(), handlerPhase.v2());
}
registerContextPhases(nodeOperations, context);
LOGGER.trace("prepareOnHandler: nodeOperations={}, handlerPhases={}, targetSourceMap={}", nodeOperations, handlerPhases, context.opCtx.targetToSourceMap);
IntHashSet leafs = new IntHashSet();
for (Tuple<ExecutionPhase, RowConsumer> handlerPhase : handlerPhases) {
ExecutionPhase phase = handlerPhase.v1();
createContexts(phase, context);
leafs.add(phase.phaseId());
}
leafs.addAll(context.opCtx.findLeafs());
for (IntCursor cursor : leafs) {
prepareSourceOperations(cursor.value, context);
}
assert context.opCtx.allNodeOperationContextsBuilt() : "some nodeOperations haven't been processed";
return context.directResponseFutures;
}
use of io.crate.execution.dsl.phases.ExecutionPhase in project crate by crate.
the class ExplainPlan method extractPhasesTimingsFrom.
private static Map<String, Object> extractPhasesTimingsFrom(Map<String, Map<String, Object>> timingsByNodeId, NodeOperationTree operationTree) {
Map<String, Object> allPhases = new TreeMap<>();
for (NodeOperation operation : operationTree.nodeOperations()) {
ExecutionPhase phase = operation.executionPhase();
getPhaseTimingsAndAddThemToPhasesMap(phase, timingsByNodeId, allPhases);
}
ExecutionPhase leafExecutionPhase = operationTree.leaf();
getPhaseTimingsAndAddThemToPhasesMap(leafExecutionPhase, timingsByNodeId, allPhases);
return allPhases;
}
use of io.crate.execution.dsl.phases.ExecutionPhase in project crate by crate.
the class NodeOperationCtxTest method testIsUpstreamOnSameNodeWithSameNodeOptimization.
@Test
public void testIsUpstreamOnSameNodeWithSameNodeOptimization() {
ExecutionPhase p1 = StubPhases.newUpstreamPhase(0, DEFAULT_BROADCAST, "n1");
ExecutionPhase p2 = newPhase(1, "n1");
NodeOperationCtx opCtx = new NodeOperationCtx("n1", singletonList(NodeOperation.withDownstream(p1, p2, (byte) 0)));
// withDownstream set DistributionInfo to SAME_NODE because both phases are on n1
assertThat(opCtx.upstreamsAreOnSameNode(1), is(true));
}
use of io.crate.execution.dsl.phases.ExecutionPhase in project crate by crate.
the class NodeOperationCtxTest method testIsUpstreamOnSameNodeWithUpstreamOnOtherNode.
@Test
public void testIsUpstreamOnSameNodeWithUpstreamOnOtherNode() {
ExecutionPhase p1 = StubPhases.newUpstreamPhase(0, DEFAULT_BROADCAST, "n2");
ExecutionPhase p2 = newPhase(1, "n1");
NodeOperationCtx opCtx = new NodeOperationCtx("n1", singletonList(NodeOperation.withDownstream(p1, p2, (byte) 0)));
assertThat(opCtx.upstreamsAreOnSameNode(1), is(false));
}
Aggregations