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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations