use of io.crate.execution.jobs.JobSetup.NodeOperationCtx in project crate by crate.
the class NodeOperationCtxTest method testFindLeafs.
@Test
public void testFindLeafs() {
ExecutionPhase p1 = newPhase(0, "n1", "n2");
ExecutionPhase p2 = newPhase(1, "n1", "n2");
ExecutionPhase p3 = newPhase(2, "n2");
NodeOperationCtx opCtx = new NodeOperationCtx("n1", List.of(NodeOperation.withDownstream(p1, p2, (byte) 0), NodeOperation.withDownstream(p2, p3, (byte) 0)));
assertThat(opCtx.findLeafs(), is(IntArrayList.from(2)));
}
use of io.crate.execution.jobs.JobSetup.NodeOperationCtx 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.jobs.JobSetup.NodeOperationCtx 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.jobs.JobSetup.NodeOperationCtx 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));
}
use of io.crate.execution.jobs.JobSetup.NodeOperationCtx in project crate by crate.
the class NodeOperationCtxTest method testFindLeafWithNodeOperationsThatHaveNoLeaf.
@Test
public void testFindLeafWithNodeOperationsThatHaveNoLeaf() {
ExecutionPhase p1 = newPhase(0, "n1");
NodeOperationCtx opCtx = new NodeOperationCtx("n1", singletonList(NodeOperation.withDownstream(p1, p1, (byte) 0)));
assertThat(stream(opCtx.findLeafs().spliterator(), false).count(), is(0L));
}
Aggregations