Search in sources :

Example 1 with PageConsumerOperator

use of com.facebook.presto.testing.PageConsumerOperator in project presto by prestodb.

the class TestDriver method testAbruptFinish.

@Test
public void testAbruptFinish() {
    List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
    ValuesOperator source = new ValuesOperator(driverContext.addOperatorContext(0, new PlanNodeId("test"), "values"), types, rowPagesBuilder(types).addSequencePage(10, 20, 30, 40).build());
    PageConsumerOperator sink = createSinkOperator(source);
    Driver driver = new Driver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    driver.close();
    assertTrue(driver.isFinished());
    // finish is only called in normal operations
    assertFalse(source.isFinished());
    assertFalse(sink.isFinished());
    // close is always called (values operator doesn't have a closed state)
    assertTrue(sink.isClosed());
}
Also used : PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.spi.type.Type) Test(org.testng.annotations.Test)

Example 2 with PageConsumerOperator

use of com.facebook.presto.testing.PageConsumerOperator in project presto by prestodb.

the class TestDriver method testAddSourceFinish.

@Test
public void testAddSourceFinish() {
    PlanNodeId sourceId = new PlanNodeId("source");
    final List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
    TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(99, new PlanNodeId("test"), "values"), sourceId, new PageSourceProvider() {

        @Override
        public ConnectorPageSource createPageSource(Session session, Split split, List<ColumnHandle> columns) {
            return new FixedPageSource(rowPagesBuilder(types).addSequencePage(10, 20, 30, 40).build());
        }
    }, types, ImmutableList.of());
    PageConsumerOperator sink = createSinkOperator(source);
    Driver driver = new Driver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    assertFalse(driver.processFor(new Duration(1, TimeUnit.MILLISECONDS)).isDone());
    assertFalse(driver.isFinished());
    driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, newMockSplit())), true));
    assertFalse(driver.isFinished());
    assertTrue(driver.processFor(new Duration(1, TimeUnit.SECONDS)).isDone());
    assertTrue(driver.isFinished());
    assertTrue(sink.isFinished());
    assertTrue(source.isFinished());
}
Also used : PageSourceProvider(com.facebook.presto.split.PageSourceProvider) ColumnHandle(com.facebook.presto.spi.ColumnHandle) ScheduledSplit(com.facebook.presto.ScheduledSplit) Duration(io.airlift.units.Duration) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) FixedPageSource(com.facebook.presto.spi.FixedPageSource) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.spi.type.Type) ScheduledSplit(com.facebook.presto.ScheduledSplit) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) TaskSource(com.facebook.presto.TaskSource) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

Example 3 with PageConsumerOperator

use of com.facebook.presto.testing.PageConsumerOperator in project presto by prestodb.

the class TestDriver method testAbruptFinish.

private void testAbruptFinish(DriverContext driverContext) {
    List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
    ValuesOperator source = new ValuesOperator(driverContext.addOperatorContext(0, new PlanNodeId("test"), "values"), rowPagesBuilder(types).addSequencePage(10, 20, 30, 40).build());
    PageConsumerOperator sink = createSinkOperator(driverContext, types);
    Driver driver = Driver.createDriver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    driver.close();
    assertTrue(driver.isFinished());
    // finish is only called in normal operations
    assertFalse(source.isFinished());
    assertFalse(sink.isFinished());
    // close is always called (values operator doesn't have a closed state)
    assertTrue(sink.isClosed());
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.common.type.Type)

Example 4 with PageConsumerOperator

use of com.facebook.presto.testing.PageConsumerOperator in project presto by prestodb.

the class TestDriver method testAddSourceFinish.

private void testAddSourceFinish(DriverContext driverContext) {
    PlanNodeId sourceId = new PlanNodeId("source");
    final List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
    TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(99, new PlanNodeId("test"), "values"), sourceId, (session, split, table, columns) -> new FixedPageSource(rowPagesBuilder(types).addSequencePage(10, 20, 30, 40).build()), TESTING_TABLE_HANDLE, ImmutableList.of());
    PageConsumerOperator sink = createSinkOperator(driverContext, types);
    Driver driver = Driver.createDriver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    assertFalse(driver.processFor(new Duration(1, TimeUnit.MILLISECONDS)).isDone());
    assertFalse(driver.isFinished());
    driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, newMockSplit())), true));
    assertFalse(driver.isFinished());
    assertTrue(driver.processFor(new Duration(1, TimeUnit.SECONDS)).isDone());
    assertTrue(driver.isFinished());
    assertTrue(sink.isFinished());
    assertTrue(source.isFinished());
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.common.type.Type) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) Duration(io.airlift.units.Duration) FixedPageSource(com.facebook.presto.spi.FixedPageSource) TaskSource(com.facebook.presto.execution.TaskSource)

Example 5 with PageConsumerOperator

use of com.facebook.presto.testing.PageConsumerOperator in project presto by prestodb.

the class TestDriver method processSourceDriver.

private void processSourceDriver(DriverContext driverContext) {
    PlanNodeId sourceId = new PlanNodeId("source");
    final List<Type> types = ImmutableList.of(VARCHAR, BIGINT, BIGINT);
    TableScanOperator source = new TableScanOperator(driverContext.addOperatorContext(99, new PlanNodeId("test"), "values"), sourceId, (session, split, table, columns) -> new FixedPageSource(rowPagesBuilder(types).addSequencePage(10, 20, 30, 40).build()), TESTING_TABLE_HANDLE, ImmutableList.of());
    PageConsumerOperator sink = createSinkOperator(driverContext, types);
    Driver driver = Driver.createDriver(driverContext, source, sink);
    assertSame(driver.getDriverContext(), driverContext);
    assertFalse(driver.isFinished());
    assertFalse(driver.processFor(new Duration(1, TimeUnit.MILLISECONDS)).isDone());
    assertFalse(driver.isFinished());
    driver.updateSource(new TaskSource(sourceId, ImmutableSet.of(new ScheduledSplit(0, sourceId, newMockSplit())), true));
    assertFalse(driver.isFinished());
    assertTrue(driver.processFor(new Duration(1, TimeUnit.SECONDS)).isDone());
    assertTrue(driver.isFinished());
    assertTrue(sink.isFinished());
    assertTrue(source.isFinished());
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PageConsumerOperator(com.facebook.presto.testing.PageConsumerOperator) Type(com.facebook.presto.common.type.Type) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) Duration(io.airlift.units.Duration) FixedPageSource(com.facebook.presto.spi.FixedPageSource) TaskSource(com.facebook.presto.execution.TaskSource)

Aggregations

PageConsumerOperator (com.facebook.presto.testing.PageConsumerOperator)6 Type (com.facebook.presto.common.type.Type)4 FixedPageSource (com.facebook.presto.spi.FixedPageSource)4 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)4 Duration (io.airlift.units.Duration)4 ScheduledSplit (com.facebook.presto.execution.ScheduledSplit)3 TaskSource (com.facebook.presto.execution.TaskSource)3 Test (org.testng.annotations.Test)3 Split (com.facebook.presto.metadata.Split)2 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)2 Type (com.facebook.presto.spi.type.Type)2 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)2 ScheduledSplit (com.facebook.presto.ScheduledSplit)1 Session (com.facebook.presto.Session)1 TaskSource (com.facebook.presto.TaskSource)1 Driver (com.facebook.presto.operator.Driver)1 TableScanOperator (com.facebook.presto.operator.TableScanOperator)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ConnectorId (com.facebook.presto.spi.ConnectorId)1 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)1