Search in sources :

Example 1 with ByteArrayBlockBuilder

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

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(com.facebook.presto.common.block.ByteArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 2 with ByteArrayBlockBuilder

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

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(com.facebook.presto.common.block.ByteArrayBlockBuilder)

Example 3 with ByteArrayBlockBuilder

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

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(com.facebook.presto.common.block.ByteArrayBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) ByteArrayBlockBuilder(com.facebook.presto.common.block.ByteArrayBlockBuilder) Test(org.testng.annotations.Test)

Aggregations

ByteArrayBlockBuilder (com.facebook.presto.common.block.ByteArrayBlockBuilder)3 Test (org.testng.annotations.Test)2 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)1 Slice (io.airlift.slice.Slice)1