Search in sources :

Example 1 with DriverYieldSignal

use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.

the class TestPageFunctionCompiler method testGeneratedClassName.

@Test
public void testGeneratedClassName() {
    PageFunctionCompiler functionCompiler = new PageFunctionCompiler(createTestMetadataManager(), 0);
    String planNodeId = "7";
    String stageId = "20170707_223500_67496_zguwn.2";
    String classSuffix = stageId + "_" + planNodeId;
    Supplier<PageProjection> projectionSupplier = functionCompiler.compileProjection(SESSION.getSqlFunctionProperties(), ADD_10_EXPRESSION, Optional.of(classSuffix));
    PageProjection projection = projectionSupplier.get();
    Work<List<Block>> work = projection.project(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), createLongBlockPage(1, 0), SelectedPositions.positionsRange(0, 1));
    // class name should look like PageProjectionOutput_20170707_223500_67496_zguwn_2_7_XX
    assertTrue(work.getClass().getSimpleName().startsWith("PageProjectionWork_" + stageId.replace('.', '_') + "_" + planNodeId));
}
Also used : PageProjection(com.facebook.presto.operator.project.PageProjection) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List) Test(org.testng.annotations.Test)

Example 2 with DriverYieldSignal

use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.

the class TestPageFunctionCompiler method project.

private List<Block> project(PageProjection projection, Page page, SelectedPositions selectedPositions) {
    Work<List<Block>> work = projection.project(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), page, selectedPositions);
    assertTrue(work.process());
    return work.getResult();
}
Also used : DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) List(java.util.List)

Example 3 with DriverYieldSignal

use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.

the class CommonSubExpressionBenchmark method ComputeRecordSet.

@Benchmark
public Optional<Page> ComputeRecordSet() {
    List<Type> types = ImmutableList.of(TYPE_MAP.get(this.functionType));
    PageBuilder pageBuilder = new PageBuilder(projectionTypes);
    RecordSet recordSet = new PageRecordSet(types, inputPage);
    cursorProcessor.process(null, new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    return Optional.of(pageBuilder.build());
}
Also used : Type(com.facebook.presto.common.type.Type) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) PageBuilder(com.facebook.presto.common.PageBuilder) SequencePageBuilder(com.facebook.presto.SequencePageBuilder) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 4 with DriverYieldSignal

use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.

the class TestCursorProcessorCompiler method testCompilerWithCSE.

@Test
public void testCompilerWithCSE() {
    PageFunctionCompiler functionCompiler = new PageFunctionCompiler(METADATA, 0);
    ExpressionCompiler expressionCompiler = new ExpressionCompiler(METADATA, functionCompiler);
    RowExpression filter = new SpecialFormExpression(AND, BIGINT, ADD_X_Y_GREATER_THAN_2, ADD_X_Y_LESS_THAN_10);
    List<? extends RowExpression> projections = createIfProjectionList(5);
    Supplier<CursorProcessor> cseCursorProcessorSupplier = expressionCompiler.compileCursorProcessor(SESSION.getSqlFunctionProperties(), Optional.of(filter), projections, "key", true);
    Supplier<CursorProcessor> noCseSECursorProcessorSupplier = expressionCompiler.compileCursorProcessor(SESSION.getSqlFunctionProperties(), Optional.of(filter), projections, "key", false);
    Page input = createLongBlockPage(2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    List<Type> types = ImmutableList.of(BIGINT, BIGINT);
    PageBuilder pageBuilder = new PageBuilder(projections.stream().map(RowExpression::getType).collect(toList()));
    RecordSet recordSet = new PageRecordSet(types, input);
    cseCursorProcessorSupplier.get().process(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    Page pageFromCSE = pageBuilder.build();
    pageBuilder.reset();
    noCseSECursorProcessorSupplier.get().process(SESSION.getSqlFunctionProperties(), new DriverYieldSignal(), recordSet.cursor(), pageBuilder);
    Page pageFromNoCSE = pageBuilder.build();
    checkPageEqual(pageFromCSE, pageFromNoCSE);
}
Also used : CursorProcessor(com.facebook.presto.operator.project.CursorProcessor) RowExpression(com.facebook.presto.spi.relation.RowExpression) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) Page(com.facebook.presto.common.Page) PageBuilder(com.facebook.presto.common.PageBuilder) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) Type(com.facebook.presto.common.type.Type) PageRecordSet(com.facebook.presto.operator.index.PageRecordSet) RecordSet(com.facebook.presto.spi.RecordSet) SpecialFormExpression(com.facebook.presto.spi.relation.SpecialFormExpression) Test(org.testng.annotations.Test)

Example 5 with DriverYieldSignal

use of com.facebook.presto.operator.DriverYieldSignal in project presto by prestodb.

the class TestPageProcessorCompiler method testSanityFilterOnDictionary.

@Test
public void testSanityFilterOnDictionary() {
    FunctionAndTypeManager functionAndTypeManager = createTestMetadataManager().getFunctionAndTypeManager();
    CallExpression lengthVarchar = new CallExpression("length", functionAndTypeManager.lookupFunction("length", fromTypes(VARCHAR)), BIGINT, ImmutableList.of(field(0, VARCHAR)));
    FunctionHandle lessThan = functionAndTypeManager.resolveOperator(LESS_THAN, fromTypes(BIGINT, BIGINT));
    CallExpression filter = new CallExpression(LESS_THAN.name(), lessThan, BOOLEAN, ImmutableList.of(lengthVarchar, constant(10L, BIGINT)));
    PageProcessor processor = compiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.of(filter), ImmutableList.of(field(0, VARCHAR)), false, 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(com.facebook.presto.operator.project.PageProcessor) FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) BlockAssertions.createLongDictionaryBlock(com.facebook.presto.block.BlockAssertions.createLongDictionaryBlock) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) Page(com.facebook.presto.common.Page) CallExpression(com.facebook.presto.spi.relation.CallExpression) FunctionHandle(com.facebook.presto.spi.function.FunctionHandle) Test(org.testng.annotations.Test)

Aggregations

DriverYieldSignal (com.facebook.presto.operator.DriverYieldSignal)27 Page (com.facebook.presto.common.Page)23 Test (org.testng.annotations.Test)19 ImmutableList (com.google.common.collect.ImmutableList)9 Optional (java.util.Optional)9 List (java.util.List)8 Type (com.facebook.presto.common.type.Type)7 PageProcessor (com.facebook.presto.operator.project.PageProcessor)7 BlockAssertions.createLongSequenceBlock (com.facebook.presto.block.BlockAssertions.createLongSequenceBlock)6 Block (com.facebook.presto.common.block.Block)6 DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)6 LazyBlock (com.facebook.presto.common.block.LazyBlock)6 CallExpression (com.facebook.presto.spi.relation.CallExpression)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)6 LocalMemoryContext (com.facebook.presto.memory.context.LocalMemoryContext)5 Slice (io.airlift.slice.Slice)5 RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)4 VariableWidthBlock (com.facebook.presto.common.block.VariableWidthBlock)4 AggregatedMemoryContext (com.facebook.presto.memory.context.AggregatedMemoryContext)4 AggregatedMemoryContext.newSimpleAggregatedMemoryContext (com.facebook.presto.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext)4