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