Search in sources :

Example 6 with VariableWidthBlockBuilder

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

the class TestInt128ArrayBlock method testLazyBlockBuilderInitialization.

@Test
public void testLazyBlockBuilderInitialization() {
    Slice[] expectedValues = createTestValue(100);
    BlockBuilder emptyBlockBuilder = new VariableWidthBlockBuilder(null, 0, 0);
    BlockBuilder blockBuilder = new VariableWidthBlockBuilder(null, expectedValues.length, 32 * 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 : VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) Int128ArrayBlockBuilder(com.facebook.presto.common.block.Int128ArrayBlockBuilder) VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Test(org.testng.annotations.Test)

Example 7 with VariableWidthBlockBuilder

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

the class TestLongArrayBlock method testLazyBlockBuilderInitialization.

@Test
public void testLazyBlockBuilderInitialization() {
    Slice[] expectedValues = createTestValue(100);
    BlockBuilder emptyBlockBuilder = new VariableWidthBlockBuilder(null, 0, 0);
    BlockBuilder blockBuilder = new VariableWidthBlockBuilder(null, expectedValues.length, 32 * 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 : VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) LongArrayBlockBuilder(com.facebook.presto.common.block.LongArrayBlockBuilder) VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Test(org.testng.annotations.Test)

Example 8 with VariableWidthBlockBuilder

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

the class TestRunLengthEncodedBlock method createSingleValueBlock.

private static Block createSingleValueBlock(Slice expectedValue) {
    BlockBuilder blockBuilder = new VariableWidthBlockBuilder(null, 1, expectedValue.length());
    blockBuilder.writeBytes(expectedValue, 0, expectedValue.length()).closeEntry();
    return blockBuilder.build();
}
Also used : VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) LongArrayBlockBuilder(com.facebook.presto.common.block.LongArrayBlockBuilder) IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) ShortArrayBlockBuilder(com.facebook.presto.common.block.ShortArrayBlockBuilder) VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) ByteArrayBlockBuilder(com.facebook.presto.common.block.ByteArrayBlockBuilder)

Example 9 with VariableWidthBlockBuilder

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

the class TestVariableWidthBlock method testLazyBlockBuilderInitialization.

@Test
public void testLazyBlockBuilderInitialization() {
    Slice[] expectedValues = createExpectedValues(100);
    BlockBuilder emptyBlockBuilder = new VariableWidthBlockBuilder(null, 0, 0);
    BlockBuilder blockBuilder = new VariableWidthBlockBuilder(null, expectedValues.length, 32 * 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 : VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Test(org.testng.annotations.Test)

Example 10 with VariableWidthBlockBuilder

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

the class MapFlatSelectiveStreamReader method getSliceKeysBlock.

private Block getSliceKeysBlock(List<DwrfSequenceEncoding> sequenceEncodings) {
    int bytes = 0;
    for (DwrfSequenceEncoding sequenceEncoding : sequenceEncodings) {
        bytes += sequenceEncoding.getKey().getBytesKey().size();
    }
    VariableWidthBlockBuilder builder = new VariableWidthBlockBuilder(null, sequenceEncodings.size(), bytes);
    for (int i = 0; i < keyCount; i++) {
        Slice key = Slices.wrappedBuffer(sequenceEncodings.get(keyIndices[i]).getKey().getBytesKey().toByteArray());
        builder.writeBytes(key, 0, key.length());
        builder.closeEntry();
    }
    return builder.build();
}
Also used : VariableWidthBlockBuilder(com.facebook.presto.common.block.VariableWidthBlockBuilder) Slice(io.airlift.slice.Slice) DwrfSequenceEncoding(com.facebook.presto.orc.metadata.DwrfSequenceEncoding)

Aggregations

VariableWidthBlockBuilder (com.facebook.presto.common.block.VariableWidthBlockBuilder)10 Slice (io.airlift.slice.Slice)6 Test (org.testng.annotations.Test)6 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)5 Block (com.facebook.presto.common.block.Block)2 LongArrayBlockBuilder (com.facebook.presto.common.block.LongArrayBlockBuilder)2 DwrfSequenceEncoding (com.facebook.presto.orc.metadata.DwrfSequenceEncoding)2 ByteArrayBlockBuilder (com.facebook.presto.common.block.ByteArrayBlockBuilder)1 Int128ArrayBlockBuilder (com.facebook.presto.common.block.Int128ArrayBlockBuilder)1 IntArrayBlockBuilder (com.facebook.presto.common.block.IntArrayBlockBuilder)1 ShortArrayBlockBuilder (com.facebook.presto.common.block.ShortArrayBlockBuilder)1 VariableWidthBlock (com.facebook.presto.common.block.VariableWidthBlock)1 VarcharType (com.facebook.presto.common.type.VarcharType)1 VarcharType.createUnboundedVarcharType (com.facebook.presto.common.type.VarcharType.createUnboundedVarcharType)1 BigDecimal (java.math.BigDecimal)1