Search in sources :

Example 21 with BlockBuilder

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

the class TypedKeyValueHeap method copy.

public TypedKeyValueHeap copy() {
    BlockBuilder keyBlockBuilderCopy = null;
    if (keyBlockBuilder != null) {
        keyBlockBuilderCopy = (BlockBuilder) keyBlockBuilder.copyRegion(0, keyBlockBuilder.getPositionCount());
    }
    BlockBuilder valueBlockBuilderCopy = null;
    if (valueBlockBuilder != null) {
        valueBlockBuilderCopy = (BlockBuilder) valueBlockBuilder.copyRegion(0, valueBlockBuilder.getPositionCount());
    }
    return new TypedKeyValueHeap(keyGreaterThan, keyType, valueType, capacity, positionCount, heapIndex.clone(), keyBlockBuilderCopy, valueBlockBuilderCopy);
}
Also used : BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 22 with BlockBuilder

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

the class ArrayAggregationFunction method output.

public static void output(Type elementType, ArrayAggregationState state, BlockBuilder out) {
    if (state.isEmpty()) {
        out.appendNull();
    } else {
        BlockBuilder entryBuilder = out.beginBlockEntry();
        state.forEach((block, position) -> elementType.appendTo(block, position, entryBuilder));
        out.closeEntry();
    }
}
Also used : BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 23 with BlockBuilder

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

the class KeyValuePairs method copy.

public KeyValuePairs copy() {
    BlockBuilder keyBlockBuilderCopy = null;
    if (keyBlockBuilder != null) {
        keyBlockBuilderCopy = (BlockBuilder) keyBlockBuilder.copyRegion(0, keyBlockBuilder.getPositionCount());
    }
    BlockBuilder valueBlockBuilderCopy = null;
    if (valueBlockBuilder != null) {
        valueBlockBuilderCopy = (BlockBuilder) valueBlockBuilder.copyRegion(0, valueBlockBuilder.getPositionCount());
    }
    return new KeyValuePairs(keyBlockBuilderCopy, keyType, keyEqualOperator, keyHashCodeOperator, valueBlockBuilderCopy, valueType, keyPositionByHash.clone(), hashCapacity, maxFill, hashMask);
}
Also used : BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 24 with BlockBuilder

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

the class KeyValuePairs method serialize.

public void serialize(BlockBuilder out) {
    BlockBuilder mapBlockBuilder = out.beginBlockEntry();
    for (int i = 0; i < keyBlockBuilder.getPositionCount(); i++) {
        keyType.appendTo(keyBlockBuilder, i, mapBlockBuilder);
        valueType.appendTo(valueBlockBuilder, i, mapBlockBuilder);
    }
    out.closeEntry();
}
Also used : BlockBuilder(io.trino.spi.block.BlockBuilder)

Example 25 with BlockBuilder

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

the class SequenceFunction method fixedWidthSequence.

private static Block fixedWidthSequence(long start, long stop, long step, FixedWidthType type) {
    checkValidStep(start, stop, step);
    int length = toIntExact((stop - start) / step + 1L);
    checkMaxEntry(length);
    BlockBuilder blockBuilder = type.createBlockBuilder(null, length);
    for (long i = 0, value = start; i < length; ++i, value += step) {
        type.writeLong(blockBuilder, value);
    }
    return blockBuilder.build();
}
Also used : BlockBuilder(io.trino.spi.block.BlockBuilder)

Aggregations

BlockBuilder (io.trino.spi.block.BlockBuilder)459 Block (io.trino.spi.block.Block)98 Test (org.testng.annotations.Test)89 Slice (io.airlift.slice.Slice)87 Type (io.trino.spi.type.Type)61 SqlType (io.trino.spi.function.SqlType)52 Page (io.trino.spi.Page)41 ArrayType (io.trino.spi.type.ArrayType)41 RowType (io.trino.spi.type.RowType)35 MapType (io.trino.spi.type.MapType)34 Map (java.util.Map)25 PageBuilder (io.trino.spi.PageBuilder)22 VarcharType (io.trino.spi.type.VarcharType)22 ScalarFunction (io.trino.spi.function.ScalarFunction)21 TypeParameter (io.trino.spi.function.TypeParameter)20 UsedByGeneratedCode (io.trino.annotation.UsedByGeneratedCode)19 TrinoException (io.trino.spi.TrinoException)18 RowBlockBuilder (io.trino.spi.block.RowBlockBuilder)18 VariableWidthBlockBuilder (io.trino.spi.block.VariableWidthBlockBuilder)17 Description (io.trino.spi.function.Description)16