Search in sources :

Example 6 with BlockBuilder

use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.

the class BooleanEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(null, size);
    Slice slice = columnData.getSlice();
    for (int i = 0; i < size; i++) {
        int offset = columnData.getOffset(i);
        int length = columnData.getLength(i);
        if (isTrue(slice, offset, length)) {
            type.writeBoolean(builder, true);
        } else if (isFalse(slice, offset, length)) {
            type.writeBoolean(builder, false);
        } else {
            builder.appendNull();
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 7 with BlockBuilder

use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.

the class DecimalEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(null, 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 if (isShortDecimal(type)) {
            type.writeLong(builder, parseLong(slice, offset, length));
        } else {
            type.writeSlice(builder, parseSlice(slice, offset, length));
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 8 with BlockBuilder

use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.

the class FloatEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) throws RcFileCorruptionException {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(null, 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, Float.floatToIntBits(parseFloat(slice, offset, length)));
        }
    }
    return builder.build();
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(com.facebook.presto.common.block.BlockBuilder)

Example 9 with BlockBuilder

use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.

the class LongEncoding method decodeColumn.

@Override
public Block decodeColumn(ColumnData columnData) {
    int size = columnData.rowCount();
    BlockBuilder builder = type.createBlockBuilder(null, 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.common.block.BlockBuilder)

Example 10 with BlockBuilder

use of com.facebook.presto.common.block.BlockBuilder 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(null, 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.common.block.BlockBuilder)

Aggregations

BlockBuilder (com.facebook.presto.common.block.BlockBuilder)493 Block (com.facebook.presto.common.block.Block)124 Test (org.testng.annotations.Test)106 Slice (io.airlift.slice.Slice)85 Type (com.facebook.presto.common.type.Type)76 Page (com.facebook.presto.common.Page)49 SqlType (com.facebook.presto.spi.function.SqlType)46 ArrayType (com.facebook.presto.common.type.ArrayType)44 MapType (com.facebook.presto.common.type.MapType)32 RowType (com.facebook.presto.common.type.RowType)28 ScalarFunction (com.facebook.presto.spi.function.ScalarFunction)26 RowBlockBuilder (com.facebook.presto.common.block.RowBlockBuilder)22 PrestoException (com.facebook.presto.spi.PrestoException)22 PageBuilder (com.facebook.presto.common.PageBuilder)21 StructuralTestUtil.appendToBlockBuilder (com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)21 Map (java.util.Map)21 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)20 BlockAssertions.createLongsBlock (com.facebook.presto.block.BlockAssertions.createLongsBlock)19 DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)18 MapBlockBuilder (com.facebook.presto.common.block.MapBlockBuilder)18