Search in sources :

Example 1 with IntArrayBlockBuilder

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);
}
Also used : IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 2 with IntArrayBlockBuilder

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;
}
Also used : IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder)

Example 3 with IntArrayBlockBuilder

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());
}
Also used : IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 4 with IntArrayBlockBuilder

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));
}
Also used : IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 5 with IntArrayBlockBuilder

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();
}
Also used : IntArrayBlockBuilder(com.facebook.presto.common.block.IntArrayBlockBuilder) Page(com.facebook.presto.common.Page)

Aggregations

IntArrayBlockBuilder (com.facebook.presto.common.block.IntArrayBlockBuilder)6 Test (org.testng.annotations.Test)4 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)3 Page (com.facebook.presto.common.Page)1 Block (com.facebook.presto.common.block.Block)1 Slice (io.airlift.slice.Slice)1