Search in sources :

Example 1 with NodeOperationCtx

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)));
}
Also used : ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) NodeOperationCtx(io.crate.execution.jobs.JobSetup.NodeOperationCtx) Test(org.junit.Test)

Example 2 with NodeOperationCtx

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));
}
Also used : ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) NodeOperationCtx(io.crate.execution.jobs.JobSetup.NodeOperationCtx) Test(org.junit.Test)

Example 3 with NodeOperationCtx

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));
}
Also used : ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) NodeOperationCtx(io.crate.execution.jobs.JobSetup.NodeOperationCtx) Test(org.junit.Test)

Example 4 with NodeOperationCtx

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));
}
Also used : ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) NodeOperationCtx(io.crate.execution.jobs.JobSetup.NodeOperationCtx) Test(org.junit.Test)

Example 5 with NodeOperationCtx

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));
}
Also used : ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) NodeOperationCtx(io.crate.execution.jobs.JobSetup.NodeOperationCtx) Test(org.junit.Test)

Aggregations

ExecutionPhase (io.crate.execution.dsl.phases.ExecutionPhase)5 NodeOperationCtx (io.crate.execution.jobs.JobSetup.NodeOperationCtx)5 Test (org.junit.Test)5