Search in sources :

Example 16 with RunLengthEncodedBlock

use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.

the class TestApproximatePercentileAggregation method createRLEBlock.

private static RunLengthEncodedBlock createRLEBlock(Iterable<Double> percentiles, int positionCount) {
    BlockBuilder rleBlockBuilder = new ArrayType(DOUBLE).createBlockBuilder(null, 1);
    BlockBuilder arrayBlockBuilder = rleBlockBuilder.beginBlockEntry();
    for (double percentile : percentiles) {
        DOUBLE.writeDouble(arrayBlockBuilder, percentile);
    }
    rleBlockBuilder.closeEntry();
    return new RunLengthEncodedBlock(rleBlockBuilder.build(), positionCount);
}
Also used : ArrayType(io.trino.spi.type.ArrayType) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 17 with RunLengthEncodedBlock

use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.

the class TestApproximatePercentileAggregation method createRLEBlock.

private static RunLengthEncodedBlock createRLEBlock(double percentile, int positionCount) {
    BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(null, 1);
    DOUBLE.writeDouble(blockBuilder, percentile);
    return new RunLengthEncodedBlock(blockBuilder.build(), positionCount);
}
Also used : RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 18 with RunLengthEncodedBlock

use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.

the class TestPartitionedOutputOperator method testPartitionPositionsWithRleNullWithNullChannel.

@Test
public void testPartitionPositionsWithRleNullWithNullChannel() {
    PartitionedOutputOperator partitionedOutputOperator = partitionedOutputOperator(BIGINT, BIGINT).withNullChannel(0).build();
    Page page = new Page(new RunLengthEncodedBlock(createLongsBlock((Long) null), POSITIONS_PER_PAGE), createLongSequenceBlock(0, POSITIONS_PER_PAGE));
    processPages(partitionedOutputOperator, page);
    List<Object> partition0 = readLongs(outputBuffer.getEnqueuedDeserialized(0), 1);
    assertThat(partition0).containsExactlyElementsOf(readLongs(Stream.of(page), 1));
    List<Object> partition1 = readLongs(outputBuffer.getEnqueuedDeserialized(1), 1);
    assertThat(partition1).containsExactlyElementsOf(readLongs(Stream.of(page), 1));
}
Also used : Page(io.trino.spi.Page) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) Test(org.testng.annotations.Test)

Example 19 with RunLengthEncodedBlock

use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.

the class TestDictionaryAwarePageProjection method testRleBlockWithFailure.

@Test(dataProvider = "forceYield")
public void testRleBlockWithFailure(boolean forceYield, boolean produceLazyBlock) {
    Block value = createLongSequenceBlock(-43, -42);
    RunLengthEncodedBlock block = new RunLengthEncodedBlock(value, 100);
    testProjectFails(block, RunLengthEncodedBlock.class, forceYield, produceLazyBlock);
}
Also used : BlockAssertions.createLongSequenceBlock(io.trino.block.BlockAssertions.createLongSequenceBlock) DictionaryBlock(io.trino.spi.block.DictionaryBlock) LazyBlock(io.trino.spi.block.LazyBlock) Block(io.trino.spi.block.Block) LongArrayBlock(io.trino.spi.block.LongArrayBlock) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) BlockAssertions.createLongsBlock(io.trino.block.BlockAssertions.createLongsBlock) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) Test(org.testng.annotations.Test)

Example 20 with RunLengthEncodedBlock

use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.

the class DeltaLakePageSource 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, TrinoException.class);
        throw new TrinoException(DELTA_LAKE_BAD_DATA, e);
    }
}
Also used : Block(io.trino.spi.block.Block) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) TrinoException(io.trino.spi.TrinoException) Page(io.trino.spi.Page) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock)

Aggregations

RunLengthEncodedBlock (io.trino.spi.block.RunLengthEncodedBlock)41 Block (io.trino.spi.block.Block)25 Page (io.trino.spi.Page)22 Test (org.testng.annotations.Test)13 DictionaryBlock (io.trino.spi.block.DictionaryBlock)8 TrinoException (io.trino.spi.TrinoException)6 BlockBuilder (io.trino.spi.block.BlockBuilder)6 Slice (io.airlift.slice.Slice)5 BlockAssertions.createLongsBlock (io.trino.block.BlockAssertions.createLongsBlock)5 LongArrayBlock (io.trino.spi.block.LongArrayBlock)5 BlockAssertions.createLongSequenceBlock (io.trino.block.BlockAssertions.createLongSequenceBlock)4 LazyBlock (io.trino.spi.block.LazyBlock)4 Type (io.trino.spi.type.Type)4 IOException (java.io.IOException)4 Utils.nativeValueToBlock (io.trino.spi.predicate.Utils.nativeValueToBlock)3 UncheckedIOException (java.io.UncheckedIOException)3 BlockAssertions.createStringSequenceBlock (io.trino.block.BlockAssertions.createStringSequenceBlock)2 PageSplitterUtil.splitPage (io.trino.execution.buffer.PageSplitterUtil.splitPage)2 DriverYieldSignal (io.trino.operator.DriverYieldSignal)2 PageProcessor (io.trino.operator.project.PageProcessor)2