Search in sources :

Example 6 with IntArrayBlockBuilder

use of io.trino.spi.block.IntArrayBlockBuilder in project trino by trinodb.

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(io.trino.spi.block.IntArrayBlockBuilder) Page(io.trino.spi.Page)

Aggregations

IntArrayBlockBuilder (io.trino.spi.block.IntArrayBlockBuilder)6 Test (org.testng.annotations.Test)4 BlockBuilder (io.trino.spi.block.BlockBuilder)3 Slice (io.airlift.slice.Slice)1 Page (io.trino.spi.Page)1 Block (io.trino.spi.block.Block)1 BlockPositionHashCode (io.trino.type.BlockTypeOperators.BlockPositionHashCode)1