Search in sources :

Example 1 with ByteArrayBlockBuilder

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

the class TestRunLengthEncodedBlock method testBuildingFromByteArrayBlockBuilder.

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

Example 2 with ByteArrayBlockBuilder

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

the class TestByteArrayBlock method testLazyBlockBuilderInitialization.

@Test
public void testLazyBlockBuilderInitialization() {
    Slice[] expectedValues = createTestValue(100);
    BlockBuilder emptyBlockBuilder = new ByteArrayBlockBuilder(null, 0);
    BlockBuilder blockBuilder = new ByteArrayBlockBuilder(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 : Slice(io.airlift.slice.Slice) ByteArrayBlockBuilder(io.trino.spi.block.ByteArrayBlockBuilder) BlockBuilder(io.trino.spi.block.BlockBuilder) ByteArrayBlockBuilder(io.trino.spi.block.ByteArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 3 with ByteArrayBlockBuilder

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

the class TestByteArrayBlock method createBlockBuilderWithValues.

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

Aggregations

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