Search in sources :

Example 21 with DriverYieldSignal

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

the class TestPageProcessorCompiler method testSanityFilterOnRLE.

@Test
public void testSanityFilterOnRLE() {
    Signature lessThan = internalOperator(LESS_THAN, BOOLEAN, ImmutableList.of(BIGINT, BIGINT));
    CallExpression filter = new CallExpression(lessThan.getName().getObjectName(), new BuiltInFunctionHandle(lessThan), BOOLEAN, ImmutableList.of(field(0, BIGINT), constant(10L, BIGINT)), Optional.empty());
    PageProcessor processor = compiler.compilePageProcessor(Optional.of(filter), ImmutableList.of(field(0, BIGINT)), MAX_BATCH_SIZE).get();
    Page page = new Page(createRLEBlock(5L, 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 RunLengthEncodedBlock);
    RunLengthEncodedBlock rle = (RunLengthEncodedBlock) outputPage.getBlock(0);
    assertEquals(BIGINT.getLong(rle.getValue(), 0), 5L);
}
Also used : PageProcessor(io.prestosql.operator.project.PageProcessor) TypeSignature.parseTypeSignature(io.prestosql.spi.type.TypeSignature.parseTypeSignature) Signature(io.prestosql.spi.function.Signature) DriverYieldSignal(io.prestosql.operator.DriverYieldSignal) BuiltInFunctionHandle(io.prestosql.spi.function.BuiltInFunctionHandle) Page(io.prestosql.spi.Page) RunLengthEncodedBlock(io.prestosql.spi.block.RunLengthEncodedBlock) CallExpression(io.prestosql.spi.relation.CallExpression) Test(org.testng.annotations.Test)

Example 22 with DriverYieldSignal

use of io.prestosql.operator.DriverYieldSignal 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 23 with DriverYieldSignal

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

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(ADD_10_EXPRESSION, Optional.of(classSuffix));
    PageProjection projection = projectionSupplier.get();
    Work<Block> work = projection.project(SESSION, new DriverYieldSignal(), createLongBlockPage(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(io.prestosql.operator.project.PageProjection) Block(io.prestosql.spi.block.Block) DriverYieldSignal(io.prestosql.operator.DriverYieldSignal) Test(org.testng.annotations.Test)

Example 24 with DriverYieldSignal

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

the class PagesSortBenchmark method runPagesMergeSortBenchmark.

@Benchmark
public List<Page> runPagesMergeSortBenchmark(MergeSortedBenchmarkData data) {
    WorkProcessor<Page> sortedPagesWork = mergeSortedPages(data.getSplitPages().stream().map(WorkProcessor::fromIterable).collect(toImmutableList()), ORDERING_COMPILER.compilePageWithPositionComparator(data.getSortTypes(), data.getSortChannels(), data.getSortOrders()), data.getOutputChannels(), data.getTypes(), (pageBuilder, pageWithPosition) -> pageBuilder.isFull(), false, newSimpleAggregatedMemoryContext(), new DriverYieldSignal());
    ImmutableList.Builder<Page> sortedPages = ImmutableList.builder();
    while (true) {
        sortedPagesWork.process();
        if (sortedPagesWork.isFinished()) {
            return sortedPages.build();
        }
        sortedPages.add(sortedPagesWork.getResult());
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) WorkProcessor(io.prestosql.operator.WorkProcessor) DriverYieldSignal(io.prestosql.operator.DriverYieldSignal) SequencePageBuilder.createSequencePage(io.prestosql.SequencePageBuilder.createSequencePage) Page(io.prestosql.spi.Page) Benchmark(org.openjdk.jmh.annotations.Benchmark)

Example 25 with DriverYieldSignal

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

the class TestMergeSortedPages method testSortingYields.

@Test
public void testSortingYields() {
    DriverYieldSignal yieldSignal = new DriverYieldSignal();
    yieldSignal.forceYieldForTesting();
    List<Type> types = ImmutableList.of(INTEGER);
    WorkProcessor<Page> mergedPages = MergeSortedPages.mergeSortedPages(ImmutableList.of(WorkProcessor.fromIterable(rowPagesBuilder(types).row(1).build())), new SimplePageWithPositionComparator(types, ImmutableList.of(0), ImmutableList.of(DESC_NULLS_LAST)), ImmutableList.of(0), types, (pageBuilder, pageWithPosition) -> pageBuilder.isFull(), false, newSimpleAggregatedMemoryContext().newAggregatedMemoryContext(), yieldSignal);
    // yield signal is on
    assertFalse(mergedPages.process());
    yieldSignal.resetYieldForTesting();
    // page is produced
    assertTrue(mergedPages.process());
    assertFalse(mergedPages.isFinished());
    Page page = mergedPages.getResult();
    MaterializedResult expected = resultBuilder(TEST_SESSION, types).row(1).build();
    assertEquals(toMaterializedResult(TEST_SESSION, types, ImmutableList.of(page)), expected);
    // merge source finished
    assertTrue(mergedPages.process());
    assertTrue(mergedPages.isFinished());
}
Also used : Type(io.prestosql.spi.type.Type) DriverYieldSignal(io.prestosql.operator.DriverYieldSignal) Page(io.prestosql.spi.Page) SimplePageWithPositionComparator(io.prestosql.operator.SimplePageWithPositionComparator) OperatorAssertion.toMaterializedResult(io.prestosql.operator.OperatorAssertion.toMaterializedResult) MaterializedResult(io.prestosql.testing.MaterializedResult) Test(org.testng.annotations.Test)

Aggregations

DriverYieldSignal (io.prestosql.operator.DriverYieldSignal)26 Page (io.prestosql.spi.Page)22 Test (org.testng.annotations.Test)18 Block (io.prestosql.spi.block.Block)9 Optional (java.util.Optional)9 BlockAssertions.createLongSequenceBlock (io.prestosql.block.BlockAssertions.createLongSequenceBlock)7 PageProcessor (io.prestosql.operator.project.PageProcessor)7 LazyBlock (io.prestosql.spi.block.LazyBlock)7 DictionaryBlock (io.prestosql.spi.block.DictionaryBlock)6 BuiltInFunctionHandle (io.prestosql.spi.function.BuiltInFunctionHandle)6 CallExpression (io.prestosql.spi.relation.CallExpression)6 Slice (io.airlift.slice.Slice)5 LocalMemoryContext (io.prestosql.memory.context.LocalMemoryContext)5 RunLengthEncodedBlock (io.prestosql.spi.block.RunLengthEncodedBlock)5 VariableWidthBlock (io.prestosql.spi.block.VariableWidthBlock)5 Type (io.prestosql.spi.type.Type)5 BlockAssertions.createSlicesBlock (io.prestosql.block.BlockAssertions.createSlicesBlock)4 BlockAssertions.createStringsBlock (io.prestosql.block.BlockAssertions.createStringsBlock)4 AggregatedMemoryContext (io.prestosql.memory.context.AggregatedMemoryContext)4 AggregatedMemoryContext.newSimpleAggregatedMemoryContext (io.prestosql.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext)4