Search in sources :

Example 21 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class BlockAssertions method createRLEBlock.

public static RunLengthEncodedBlock createRLEBlock(long value, int positionCount) {
    BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, 1);
    BIGINT.writeLong(blockBuilder, value);
    return new RunLengthEncodedBlock(blockBuilder.build(), positionCount);
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) RowBlockBuilder(com.facebook.presto.common.block.RowBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)

Example 22 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class TestColumnarMap method assertRunLengthEncodedBlock.

private static void assertRunLengthEncodedBlock(Block block, Slice[][][] expectedValues) {
    for (int position = 0; position < block.getPositionCount(); position++) {
        RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position);
        Slice[][][] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position);
        assertBlock(runLengthEncodedBlock, expectedDictionaryValues);
        assertColumnarMap(runLengthEncodedBlock, expectedDictionaryValues);
    }
}
Also used : Slice(io.airlift.slice.Slice) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock)

Example 23 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class TestPageProcessorCompiler method testSanityFilterOnRLE.

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

Example 24 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class TestPageProcessorCompiler method testSanityRLE.

@Test
public void testSanityRLE() {
    PageProcessor processor = compiler.compilePageProcessor(TEST_SESSION.getSqlFunctionProperties(), Optional.empty(), ImmutableList.of(field(0, BIGINT), field(1, VARCHAR)), false, MAX_BATCH_SIZE).get();
    Slice varcharValue = Slices.utf8Slice("hello");
    Page page = new Page(RunLengthEncodedBlock.create(BIGINT, 123L, 100), RunLengthEncodedBlock.create(VARCHAR, varcharValue, 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);
    assertTrue(outputPage.getBlock(1) instanceof RunLengthEncodedBlock);
    RunLengthEncodedBlock rleBlock = (RunLengthEncodedBlock) outputPage.getBlock(0);
    assertEquals(BIGINT.getLong(rleBlock.getValue(), 0), 123L);
    RunLengthEncodedBlock rleBlock1 = (RunLengthEncodedBlock) outputPage.getBlock(1);
    assertEquals(VARCHAR.getSlice(rleBlock1.getValue(), 0), varcharValue);
}
Also used : PageProcessor(com.facebook.presto.operator.project.PageProcessor) Slice(io.airlift.slice.Slice) DriverYieldSignal(com.facebook.presto.operator.DriverYieldSignal) Page(com.facebook.presto.common.Page) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Test(org.testng.annotations.Test)

Example 25 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class IcebergPageSource method getNextPage.

@Override
public Page getNextPage() {
    try {
        Page dataPage = delegate.getNextPage();
        if (dataPage == null) {
            return null;
        }
        int batchSize = dataPage.getPositionCount();
        Block[] blocks = new Block[prefilledBlocks.length];
        for (int i = 0; i < prefilledBlocks.length; i++) {
            if (prefilledBlocks[i] != null) {
                blocks[i] = new RunLengthEncodedBlock(prefilledBlocks[i], batchSize);
            } else {
                blocks[i] = dataPage.getBlock(delegateIndexes[i]);
            }
        }
        return new Page(batchSize, blocks);
    } catch (RuntimeException e) {
        closeWithSuppression(e);
        throwIfInstanceOf(e, PrestoException.class);
        throw new PrestoException(ICEBERG_BAD_DATA, e);
    }
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Block(com.facebook.presto.common.block.Block) Page(com.facebook.presto.common.Page) PrestoException(com.facebook.presto.spi.PrestoException) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock)

Aggregations

RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)50 Block (com.facebook.presto.common.block.Block)27 Page (com.facebook.presto.common.Page)14 Test (org.testng.annotations.Test)9 DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)7 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)6 LongArrayBlock (com.facebook.presto.common.block.LongArrayBlock)6 PrestoException (com.facebook.presto.spi.PrestoException)6 ByteArrayBlock (com.facebook.presto.common.block.ByteArrayBlock)5 Slice (io.airlift.slice.Slice)5 IOException (java.io.IOException)4 ArrayBlock (com.facebook.presto.common.block.ArrayBlock)3 LazyBlock (com.facebook.presto.common.block.LazyBlock)3 RowBlockBuilder (com.facebook.presto.common.block.RowBlockBuilder)3 BlockAssertions.createLongSequenceBlock (com.facebook.presto.block.BlockAssertions.createLongSequenceBlock)2 BlockLease (com.facebook.presto.common.block.BlockLease)2 IntArrayBlock (com.facebook.presto.common.block.IntArrayBlock)2 VariableWidthBlock (com.facebook.presto.common.block.VariableWidthBlock)2 Type (com.facebook.presto.common.type.Type)2 DriverYieldSignal (com.facebook.presto.operator.DriverYieldSignal)2