use of io.prestosql.spi.annotation.UsedByGeneratedCode in project hetu-core by openlookeng.
the class ArrayConcatFunction method concat.
@UsedByGeneratedCode
public static Block concat(Type elementType, Object state, Block[] blocks) {
int resultPositionCount = 0;
// fast path when there is at most one non empty block
Block nonEmptyBlock = null;
for (int i = 0; i < blocks.length; i++) {
resultPositionCount += blocks[i].getPositionCount();
if (blocks[i].getPositionCount() > 0) {
nonEmptyBlock = blocks[i];
}
}
if (nonEmptyBlock == null) {
return blocks[0];
}
if (resultPositionCount == nonEmptyBlock.getPositionCount()) {
return nonEmptyBlock;
}
PageBuilder pageBuilder = (PageBuilder) state;
if (pageBuilder.isFull()) {
pageBuilder.reset();
}
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(0);
for (int blockIndex = 0; blockIndex < blocks.length; blockIndex++) {
Block block = blocks[blockIndex];
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
}
pageBuilder.declarePositions(resultPositionCount);
return blockBuilder.getRegion(blockBuilder.getPositionCount() - resultPositionCount, resultPositionCount);
}
use of io.prestosql.spi.annotation.UsedByGeneratedCode in project hetu-core by openlookeng.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, long value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeLong(blockBuilder, value);
return blockBuilder.build();
}
use of io.prestosql.spi.annotation.UsedByGeneratedCode in project hetu-core by openlookeng.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, Object value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeObject(blockBuilder, value);
return blockBuilder.build();
}
use of io.prestosql.spi.annotation.UsedByGeneratedCode in project hetu-core by openlookeng.
the class ArrayConcatUtils method prependElement.
@UsedByGeneratedCode
public static Block prependElement(Type elementType, long value, Block block) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
elementType.writeLong(blockBuilder, value);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
return blockBuilder.build();
}
use of io.prestosql.spi.annotation.UsedByGeneratedCode in project hetu-core by openlookeng.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, boolean value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(null, block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeBoolean(blockBuilder, value);
return blockBuilder.build();
}
Aggregations