Java Code Examples for io.prestosql.spi.block.Block#writePositionTo()

The following examples show how to use io.prestosql.spi.block.Block#writePositionTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BenchmarkArrayFilter.java    From presto with Apache License 2.0 6 votes vote down vote up
public static Block filter(Type type, Block block, MethodHandle function)
{
    int positionCount = block.getPositionCount();
    BlockBuilder resultBuilder = type.createBlockBuilder(null, positionCount);
    for (int position = 0; position < positionCount; position++) {
        Long input = (Long) readNativeValue(type, block, position);
        Boolean keep;
        try {
            keep = (Boolean) function.invokeExact(input);
        }
        catch (Throwable t) {
            throwIfUnchecked(t);
            throw new RuntimeException(t);
        }
        if (TRUE.equals(keep)) {
            block.writePositionTo(position, resultBuilder);
        }
    }
    return resultBuilder.build();
}
 
Example 2
Source File: AbstractTestBlock.java    From presto with Apache License 2.0 5 votes vote down vote up
private static Block copyBlockViaWritePositionTo(Block block, Supplier<BlockBuilder> newBlockBuilder)
{
    BlockBuilder blockBuilder = newBlockBuilder.get();
    for (int i = 0; i < block.getPositionCount(); i++) {
        if (block.isNull(i)) {
            blockBuilder.appendNull();
        }
        else {
            block.writePositionTo(i, blockBuilder);
        }
    }
    return blockBuilder.build();
}
 
Example 3
Source File: ArrayType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writePositionTo(position, blockBuilder);
    }
}
 
Example 4
Source File: MapType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writePositionTo(position, blockBuilder);
    }
}
 
Example 5
Source File: RowType.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public void appendTo(Block block, int position, BlockBuilder blockBuilder)
{
    if (block.isNull(position)) {
        blockBuilder.appendNull();
    }
    else {
        block.writePositionTo(position, blockBuilder);
    }
}