use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.
the class DecimalEncoding 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) {
builder.appendNull();
} else if (isShortDecimal(type)) {
type.writeLong(builder, parseLong(slice, offset));
} else {
type.writeSlice(builder, parseSlice(slice, offset));
}
}
return builder.build();
}
use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.
the class FloatEncoding 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 length = columnData.getLength(i);
if (length != 0) {
checkState(length == SIZE_OF_FLOAT, "Float should be 4 bytes");
int intBits = slice.getInt(columnData.getOffset(i));
// the file format uses big endian
type.writeLong(builder, Integer.reverseBytes(intBits));
} else {
builder.appendNull();
}
}
return builder.build();
}
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) {
builder.appendNull();
} else {
type.writeLong(builder, readVInt(slice, offset, length));
}
}
return builder.build();
}
use of com.facebook.presto.spi.block.BlockBuilderStatus in project presto by prestodb.
the class ShortEncoding 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 length = columnData.getLength(i);
if (length != 0) {
checkState(length == SIZE_OF_SHORT, "Short should be 2 bytes");
type.writeLong(builder, (long) Short.reverseBytes(slice.getShort(columnData.getOffset(i))));
} else {
builder.appendNull();
}
}
return builder.build();
}
use of com.facebook.presto.spi.block.BlockBuilderStatus 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(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, Float.floatToIntBits(parseFloat(slice, offset, length)));
}
}
return builder.build();
}
Aggregations