Search in sources :

Example 71 with BlockBuilderStatus

use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.

the class LongEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(new BlockBuilderStatus(), size);
    Slice slice = columnData.getSlice();
    for (int i = 0; i < size; i++) {
        int offset = columnData.getOffset(i);
        int length = columnData.getLength(i);
        if (length == 0 || nullSequence.equals(0, nullSequence.length(), slice, offset, length)) {
            builder.appendNull();
        } else {
            type.writeLong(builder, parseLong(slice, offset, length));
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 72 with BlockBuilderStatus

use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.

the class StringEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    if (escapeByte != null) {
        columnData = unescape(columnData, escapeByte);
    }
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(new BlockBuilderStatus(), size);
    Slice slice = columnData.getSlice();
    for (int i = 0; i < size; i++) {
        int offset = columnData.getOffset(i);
        int length = columnData.getLength(i);
        if (nullSequence.equals(0, nullSequence.length(), slice, offset, length)) {
            builder.appendNull();
        } else {
            length = calculateTruncationLength(type, slice, offset, length);
            type.writeSlice(builder, slice, offset, length);
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 73 with BlockBuilderStatus

use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.

the class TimestampEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(new BlockBuilderStatus(), size);
    Slice slice = columnData.getSlice();
    for (int i = 0; i < size; i++) {
        int offset = columnData.getOffset(i);
        int length = columnData.getLength(i);
        if (length == 0 || nullSequence.equals(0, nullSequence.length(), slice, offset, length)) {
            builder.appendNull();
        } else {
            type.writeLong(builder, parseTimestamp(slice, offset, length));
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 74 with BlockBuilderStatus

use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.

the class TestLongDecimalType method decimalAsBlock.

private Block decimalAsBlock(String value) {
    Slice slice = encodeScaledValue(new BigDecimal(value));
    BlockBuilder blockBuilder = new VariableWidthBlockBuilder(new BlockBuilderStatus(), 1, slice.length());
    TYPE.writeSlice(blockBuilder, slice);
    return blockBuilder.build();
}
Also used : VariableWidthBlockBuilder(com.facebook.presto.spi.block.VariableWidthBlockBuilder) Slice(io.airlift.slice.Slice) BigDecimal(java.math.BigDecimal) VariableWidthBlockBuilder(com.facebook.presto.spi.block.VariableWidthBlockBuilder) BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Example 75 with BlockBuilderStatus

use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.

the class Utils method nativeValueToBlock.

public static Block nativeValueToBlock(Type type, Object object) {
    if (object != null && !Primitives.wrap(type.getJavaType()).isInstance(object)) {
        throw new IllegalArgumentException(String.format("Object '%s' does not match type %s", object, type.getJavaType()));
    }
    BlockBuilder blockBuilder = type.createBlockBuilder(new BlockBuilderStatus(), 1);
    writeNativeValue(type, blockBuilder, object);
    return blockBuilder.build();
}
Also used : BlockBuilder(com.facebook.presto.spi.block.BlockBuilder) BlockBuilderStatus(com.facebook.presto.spi.block.BlockBuilderStatus)

Aggregations

BlockBuilderStatus (com.facebook.presto.spi.block.BlockBuilderStatus)227 BlockBuilder (com.facebook.presto.spi.block.BlockBuilder)210 Block (com.facebook.presto.spi.block.Block)55 Slice (io.airlift.slice.Slice)43 InterleavedBlockBuilder (com.facebook.presto.spi.block.InterleavedBlockBuilder)37 Test (org.testng.annotations.Test)35 Type (com.facebook.presto.spi.type.Type)24 SqlType (com.facebook.presto.spi.function.SqlType)20 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)15 ArrayType (com.facebook.presto.type.ArrayType)14 Page (com.facebook.presto.spi.Page)12 TypeJsonUtils.appendToBlockBuilder (com.facebook.presto.type.TypeJsonUtils.appendToBlockBuilder)12 TypeParameter (com.facebook.presto.spi.function.TypeParameter)11 RowType (com.facebook.presto.type.RowType)11 OrcCorruptionException (com.facebook.presto.orc.OrcCorruptionException)10 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)10 MapType (com.facebook.presto.type.MapType)10 PrestoException (com.facebook.presto.spi.PrestoException)9 BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)8 DecimalType (com.facebook.presto.spi.type.DecimalType)8