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());
}
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());
}
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();
}
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());
}
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();
}
Aggregations