Search in sources :

Example 1 with ShortArrayBlockBuilder

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

the class TestRunLengthEncodedBlock method testBuildingFromShortArrayBlockBuilder.

@Test
public void testBuildingFromShortArrayBlockBuilder() {
    ShortArrayBlockBuilder blockBuilder = new ShortArrayBlockBuilder(null, 100);
    populateNullValues(blockBuilder, 100);
    assertEquals(blockBuilder.build().getEncodingName(), RunLengthBlockEncoding.NAME);
}
Also used : ShortArrayBlockBuilder(io.trino.spi.block.ShortArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 2 with ShortArrayBlockBuilder

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

the class TestShortArrayBlock method createBlockBuilderWithValues.

private static BlockBuilder createBlockBuilderWithValues(Slice[] expectedValues) {
    ShortArrayBlockBuilder blockBuilder = new ShortArrayBlockBuilder(null, expectedValues.length);
    writeValues(expectedValues, blockBuilder);
    return blockBuilder;
}
Also used : ShortArrayBlockBuilder(io.trino.spi.block.ShortArrayBlockBuilder)

Example 3 with ShortArrayBlockBuilder

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

the class TestShortArrayBlock method testLazyBlockBuilderInitialization.

@Test
public void testLazyBlockBuilderInitialization() {
    Slice[] expectedValues = createTestValue(100);
    BlockBuilder emptyBlockBuilder = new ShortArrayBlockBuilder(null, 0);
    BlockBuilder blockBuilder = new ShortArrayBlockBuilder(null, expectedValues.length);
    assertEquals(blockBuilder.getSizeInBytes(), emptyBlockBuilder.getSizeInBytes());
    assertEquals(blockBuilder.getRetainedSizeInBytes(), emptyBlockBuilder.getRetainedSizeInBytes());
    writeValues(expectedValues, blockBuilder);
    assertTrue(blockBuilder.getSizeInBytes() > emptyBlockBuilder.getSizeInBytes());
    assertTrue(blockBuilder.getRetainedSizeInBytes() > emptyBlockBuilder.getRetainedSizeInBytes());
    blockBuilder = blockBuilder.newBlockBuilderLike(null);
    assertEquals(blockBuilder.getSizeInBytes(), emptyBlockBuilder.getSizeInBytes());
    assertEquals(blockBuilder.getRetainedSizeInBytes(), emptyBlockBuilder.getRetainedSizeInBytes());
}
Also used : ShortArrayBlockBuilder(io.trino.spi.block.ShortArrayBlockBuilder) Slice(io.airlift.slice.Slice) ShortArrayBlockBuilder(io.trino.spi.block.ShortArrayBlockBuilder) BlockBuilder(io.trino.spi.block.BlockBuilder) Test(org.testng.annotations.Test)

Aggregations

ShortArrayBlockBuilder (io.trino.spi.block.ShortArrayBlockBuilder)3 Test (org.testng.annotations.Test)2 Slice (io.airlift.slice.Slice)1 BlockBuilder (io.trino.spi.block.BlockBuilder)1