Search in sources :

Example 1 with PageRecordSet

use of com.facebook.presto.operator.index.PageRecordSet in project presto by prestodb.

the class TestScanFilterAndProjectOperator method testRecordCursorSource.

@Test
public void testRecordCursorSource() throws Exception {
    final Page input = SequencePageBuilder.createSequencePage(ImmutableList.of(VARCHAR), 10_000, 0);
    DriverContext driverContext = newDriverContext();
    ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory factory = new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), new PlanNodeId("0"), new PageSourceProvider() {

        @Override
        public ConnectorPageSource createPageSource(Session session, Split split, List<ColumnHandle> columns) {
            return new RecordPageSource(new PageRecordSet(ImmutableList.of(VARCHAR), input));
        }
    }, () -> new GenericCursorProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), () -> new GenericPageProcessor(FilterFunctions.TRUE_FUNCTION, ImmutableList.of(singleColumn(VARCHAR, 0))), ImmutableList.of(), ImmutableList.of(VARCHAR));
    SourceOperator operator = factory.createOperator(driverContext);
    operator.addSplit(new Split(new ConnectorId("test"), TestingTransactionHandle.create(), TestingSplit.createLocalSplit()));
    operator.noMoreSplits();
    MaterializedResult expected = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), ImmutableList.of(input));
    MaterializedResult actual = toMaterializedResult(driverContext.getSession(), ImmutableList.of(VARCHAR), toPages(operator));
    assertEquals(actual.getRowCount(), expected.getRowCount());
    assertEquals(actual, expected);
}
Also used : PageSourceProvider(com.facebook.presto.split.PageSourceProvider) ColumnHandle(com.facebook.presto.spi.ColumnHandle) Page(com.facebook.presto.spi.Page) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) ConnectorPageSource(com.facebook.presto.spi.ConnectorPageSource) RecordPageSource(com.facebook.presto.spi.RecordPageSource) PlanNodeId(com.facebook.presto.sql.planner.plan.PlanNodeId) TestingSplit(com.facebook.presto.testing.TestingSplit) Split(com.facebook.presto.metadata.Split) OperatorAssertion.toMaterializedResult(com.facebook.presto.operator.OperatorAssertion.toMaterializedResult) MaterializedResult(com.facebook.presto.testing.MaterializedResult) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.connector.ConnectorId) Test(org.testng.annotations.Test)

Aggregations

Session (com.facebook.presto.Session)1 ConnectorId (com.facebook.presto.connector.ConnectorId)1 Split (com.facebook.presto.metadata.Split)1 OperatorAssertion.toMaterializedResult (com.facebook.presto.operator.OperatorAssertion.toMaterializedResult)1 PageRecordSet (com.facebook.presto.operator.index.PageRecordSet)1 ColumnHandle (com.facebook.presto.spi.ColumnHandle)1 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)1 Page (com.facebook.presto.spi.Page)1 RecordPageSource (com.facebook.presto.spi.RecordPageSource)1 PageSourceProvider (com.facebook.presto.split.PageSourceProvider)1 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)1 MaterializedResult (com.facebook.presto.testing.MaterializedResult)1 TestingSplit (com.facebook.presto.testing.TestingSplit)1 Test (org.testng.annotations.Test)1