use of com.facebook.presto.common.block.IntArrayBlockBuilder in project presto by prestodb.
the class TestRunLengthEncodedBlock method testBuildingFromIntArrayBlockBuilder.
@Test
public void testBuildingFromIntArrayBlockBuilder() {
IntArrayBlockBuilder blockBuilder = new IntArrayBlockBuilder(null, 100);
populateNullValues(blockBuilder, 100);
assertEquals(blockBuilder.build().getEncodingName(), RunLengthBlockEncoding.NAME);
}
use of com.facebook.presto.common.block.IntArrayBlockBuilder in project presto by prestodb.
the class TestIntArrayBlock method createBlockBuilderWithValues.
private static BlockBuilder createBlockBuilderWithValues(Slice[] expectedValues) {
IntArrayBlockBuilder blockBuilder = new IntArrayBlockBuilder(null, expectedValues.length);
writeValues(expectedValues, blockBuilder);
return blockBuilder;
}
use of com.facebook.presto.common.block.IntArrayBlockBuilder in project presto by prestodb.
the class TestIntArrayBlock method testLazyBlockBuilderInitialization.
@Test
public void testLazyBlockBuilderInitialization() {
Slice[] expectedValues = createTestValue(100);
BlockBuilder emptyBlockBuilder = new IntArrayBlockBuilder(null, 0);
BlockBuilder blockBuilder = new IntArrayBlockBuilder(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());
}
use of com.facebook.presto.common.block.IntArrayBlockBuilder in project presto by prestodb.
the class TestRealType method testNaNHash.
@Test
public void testNaNHash() {
BlockBuilder blockBuilder = new IntArrayBlockBuilder(null, 4);
blockBuilder.writeInt(floatToIntBits(Float.NaN));
blockBuilder.writeInt(floatToRawIntBits(Float.NaN));
// the following two are the integer values of a float NaN
blockBuilder.writeInt(-0x400000);
blockBuilder.writeInt(0x7fc00000);
assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 1));
assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 2));
assertEquals(REAL.hash(blockBuilder, 0), REAL.hash(blockBuilder, 3));
}
use of com.facebook.presto.common.block.IntArrayBlockBuilder in project presto by prestodb.
the class HivePageSink method buildBucketBlock.
private Block buildBucketBlock(Page page) {
if (bucketFunction == null) {
return null;
}
IntArrayBlockBuilder bucketColumnBuilder = new IntArrayBlockBuilder(null, page.getPositionCount());
Page bucketColumnsPage = extractColumns(page, bucketColumns);
for (int position = 0; position < page.getPositionCount(); position++) {
int bucket = bucketFunction.getBucket(bucketColumnsPage, position);
bucketColumnBuilder.writeInt(bucket);
}
return bucketColumnBuilder.build();
}
Aggregations