Search in sources :

Example 21 with PageProcessor

use of io.prestosql.operator.project.PageProcessor in project hetu-core by openlookeng.

the class TestPageProcessorCompiler method testSanityFilterOnDictionary.

@Test
public void testSanityFilterOnDictionary() {
    CallExpression lengthVarchar = new CallExpression(QualifiedObjectName.valueOfDefaultFunction("length").getObjectName(), new BuiltInFunctionHandle(new Signature(QualifiedObjectName.valueOfDefaultFunction("length"), SCALAR, parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.VARCHAR))), BIGINT, ImmutableList.of(field(0, VARCHAR)), Optional.empty());
    Signature lessThan = internalOperator(LESS_THAN, BOOLEAN, ImmutableList.of(BIGINT, BIGINT));
    CallExpression filter = new CallExpression(lessThan.getName().getObjectName(), new BuiltInFunctionHandle(lessThan), BOOLEAN, ImmutableList.of(lengthVarchar, constant(10L, BIGINT)), Optional.empty());
    PageProcessor processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(0, VARCHAR)), MAX_BATCH_SIZE).get();
    Page page = new Page(createDictionaryBlock(createExpectedValues(10), 100));
    Page outputPage = getOnlyElement(processor.process(null, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)).orElseThrow(() -> new AssertionError("page is not present"));
    assertEquals(outputPage.getPositionCount(), 100);
    assertTrue(outputPage.getBlock(0) instanceof DictionaryBlock);
    DictionaryBlock dictionaryBlock = (DictionaryBlock) outputPage.getBlock(0);
    assertEquals(dictionaryBlock.getDictionary().getPositionCount(), 10);
    // test filter caching
    Page outputPage2 = getOnlyElement(processor.process(null, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)).orElseThrow(() -> new AssertionError("page is not present"));
    assertEquals(outputPage2.getPositionCount(), 100);
    assertTrue(outputPage2.getBlock(0) instanceof DictionaryBlock);
    DictionaryBlock dictionaryBlock2 = (DictionaryBlock) outputPage2.getBlock(0);
    // both output pages must have the same dictionary
    assertEquals(dictionaryBlock2.getDictionary(), dictionaryBlock.getDictionary());
}
Also used : PageProcessor(io.prestosql.operator.project.PageProcessor) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) Signature(io.prestosql.spi.function.Signature) DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) BlockAssertions.createLongDictionaryBlock(io.prestosql.block.BlockAssertions.createLongDictionaryBlock) DriverYieldSignal(io.prestosql.operator.DriverYieldSignal) BuiltInFunctionHandle(io.prestosql.spi.function.BuiltInFunctionHandle) Page(io.prestosql.spi.Page) CallExpression(io.prestosql.spi.relation.CallExpression) Test(org.testng.annotations.Test)

Example 22 with PageProcessor

use of io.prestosql.operator.project.PageProcessor in project hetu-core by openlookeng.

the class PredicateFilterBenchmark method createOperatorFactories.

@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
    OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
    RowExpression filter = call(GREATER_THAN_OR_EQUAL.name(), localQueryRunner.getMetadata().getFunctionAndTypeManager().resolveOperatorFunctionHandle(GREATER_THAN_OR_EQUAL, fromTypes(DOUBLE, DOUBLE)), BOOLEAN, field(0, DOUBLE), constant(50000.0, DOUBLE));
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(localQueryRunner.getMetadata(), new PageFunctionCompiler(localQueryRunner.getMetadata(), 0));
    Supplier<PageProcessor> pageProcessor = expressionCompiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(0, DOUBLE)));
    FilterAndProjectOperator.FilterAndProjectOperatorFactory filterAndProjectOperator = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(1, new PlanNodeId("test"), pageProcessor, ImmutableList.of(DOUBLE), new DataSize(0, BYTE), 0);
    return ImmutableList.of(tableScanOperator, filterAndProjectOperator);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) PageProcessor(io.prestosql.operator.project.PageProcessor) OperatorFactory(io.prestosql.operator.OperatorFactory) DataSize(io.airlift.units.DataSize) RowExpression(io.prestosql.spi.relation.RowExpression) ExpressionCompiler(io.prestosql.sql.gen.ExpressionCompiler) FilterAndProjectOperator(io.prestosql.operator.FilterAndProjectOperator)

Example 23 with PageProcessor

use of io.prestosql.operator.project.PageProcessor in project hetu-core by openlookeng.

the class TestColumnarPageProcessor method testProcessWithDictionary.

@Test
public void testProcessWithDictionary() {
    PageProcessor processor = newPageProcessor();
    Page page = createPage(types, true);
    Page outputPage = getOnlyElement(processor.process(SESSION, new DriverYieldSignal(), newSimpleAggregatedMemoryContext().newLocalMemoryContext(PageProcessor.class.getSimpleName()), page)).orElseThrow(() -> new AssertionError("page is not present"));
    assertPageEquals(types, outputPage, page);
}
Also used : PageProcessor(io.prestosql.operator.project.PageProcessor) Page(io.prestosql.spi.Page) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Test(org.testng.annotations.Test)

Example 24 with PageProcessor

use of io.prestosql.operator.project.PageProcessor in project hetu-core by openlookeng.

the class TestFilterAndProjectOperator method testSnapshot.

@Test
public void testSnapshot() {
    List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).addSequencePage(100, 0, 0).addSequencePage(100, 0, 0).addSequencePage(100, 0, 0).build();
    RowExpression filter = call(BETWEEN.getFunctionName().toString(), new BuiltInFunctionHandle(Signature.internalOperator(BETWEEN, BOOLEAN.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()))), BOOLEAN, field(1, BIGINT), constant(10L, BIGINT), constant(19L, BIGINT));
    RowExpression field0 = field(0, VARCHAR);
    RowExpression add5 = call(ADD.getFunctionName().toString(), new BuiltInFunctionHandle(Signature.internalOperator(ADD, BIGINT.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()))), BIGINT, field(1, BIGINT), constant(5L, BIGINT));
    Metadata metadata = createTestMetadataManager();
    ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0));
    Supplier<PageProcessor> processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field0, add5));
    OperatorFactory operatorFactory = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(VARCHAR, BIGINT), new DataSize(0, BYTE), 0);
    MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("10", 15L).row("11", 16L).row("12", 17L).row("13", 18L).row("14", 19L).row("15", 20L).row("16", 21L).row("17", 22L).row("18", 23L).row("19", 24L).row("10", 15L).row("11", 16L).row("12", 17L).row("13", 18L).row("14", 19L).row("15", 20L).row("16", 21L).row("17", 22L).row("18", 23L).row("19", 24L).row("10", 15L).row("11", 16L).row("12", 17L).row("13", 18L).row("14", 19L).row("15", 20L).row("16", 21L).row("17", 22L).row("18", 23L).row("19", 24L).build();
    assertOperatorEqualsWithStateComparison(operatorFactory, driverContext, input, expected, false, ImmutableList.of(), true, createExpectedMapping());
}
Also used : PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) Metadata(io.prestosql.metadata.Metadata) RowExpression(io.prestosql.spi.relation.RowExpression) Page(io.prestosql.spi.Page) BuiltInFunctionHandle(io.prestosql.spi.function.BuiltInFunctionHandle) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageProcessor(io.prestosql.operator.project.PageProcessor) DataSize(io.airlift.units.DataSize) ExpressionCompiler(io.prestosql.sql.gen.ExpressionCompiler) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Example 25 with PageProcessor

use of io.prestosql.operator.project.PageProcessor in project hetu-core by openlookeng.

the class TestFilterAndProjectOperator method test.

@Test
public void test() {
    List<Page> input = rowPagesBuilder(VARCHAR, BIGINT).addSequencePage(100, 0, 0).build();
    RowExpression filter = call(BETWEEN.getFunctionName().toString(), new BuiltInFunctionHandle(Signature.internalOperator(BETWEEN, BOOLEAN.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature(), BIGINT.getTypeSignature(), BIGINT.getTypeSignature()))), BOOLEAN, field(1, BIGINT), constant(10L, BIGINT), constant(19L, BIGINT));
    RowExpression field0 = field(0, VARCHAR);
    RowExpression add5 = call(ADD.getFunctionName().toString(), new BuiltInFunctionHandle(Signature.internalOperator(ADD, BIGINT.getTypeSignature(), ImmutableList.of(BIGINT.getTypeSignature(), BIGINT.getTypeSignature()))), BIGINT, field(1, BIGINT), constant(5L, BIGINT));
    Metadata metadata = createTestMetadataManager();
    ExpressionCompiler compiler = new ExpressionCompiler(metadata, new PageFunctionCompiler(metadata, 0));
    Supplier<PageProcessor> processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field0, add5));
    OperatorFactory operatorFactory = new FilterAndProjectOperator.FilterAndProjectOperatorFactory(0, new PlanNodeId("test"), processor, ImmutableList.of(VARCHAR, BIGINT), new DataSize(0, BYTE), 0);
    MaterializedResult expected = MaterializedResult.resultBuilder(driverContext.getSession(), VARCHAR, BIGINT).row("10", 15L).row("11", 16L).row("12", 17L).row("13", 18L).row("14", 19L).row("15", 20L).row("16", 21L).row("17", 22L).row("18", 23L).row("19", 24L).build();
    assertOperatorEquals(operatorFactory, driverContext, input, expected);
}
Also used : PageFunctionCompiler(io.prestosql.sql.gen.PageFunctionCompiler) Metadata(io.prestosql.metadata.Metadata) RowExpression(io.prestosql.spi.relation.RowExpression) Page(io.prestosql.spi.Page) BuiltInFunctionHandle(io.prestosql.spi.function.BuiltInFunctionHandle) PlanNodeId(io.prestosql.spi.plan.PlanNodeId) PageProcessor(io.prestosql.operator.project.PageProcessor) DataSize(io.airlift.units.DataSize) ExpressionCompiler(io.prestosql.sql.gen.ExpressionCompiler) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

PageProcessor (io.prestosql.operator.project.PageProcessor)26 Page (io.prestosql.spi.Page)18 Test (org.testng.annotations.Test)18 RowExpression (io.prestosql.spi.relation.RowExpression)15 DataSize (io.airlift.units.DataSize)14 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)14 BuiltInFunctionHandle (io.prestosql.spi.function.BuiltInFunctionHandle)11 PageFunctionCompiler (io.prestosql.sql.gen.PageFunctionCompiler)10 CursorProcessor (io.prestosql.operator.project.CursorProcessor)9 Metadata (io.prestosql.metadata.Metadata)7 Split (io.prestosql.metadata.Split)7 DriverYieldSignal (io.prestosql.operator.DriverYieldSignal)7 CatalogName (io.prestosql.spi.connector.CatalogName)6 ExpressionCompiler (io.prestosql.sql.gen.ExpressionCompiler)6 MaterializedResult (io.prestosql.testing.MaterializedResult)6 TestingSplit (io.prestosql.testing.TestingSplit)6 UUID (java.util.UUID)6 ImmutableList (com.google.common.collect.ImmutableList)5 FixedPageSource (io.prestosql.spi.connector.FixedPageSource)5 OperatorAssertion.toMaterializedResult (io.prestosql.operator.OperatorAssertion.toMaterializedResult)4