use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class TimestampEncoding 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, parseTimestamp(slice, offset, length));
}
}
return builder.build();
}
use of com.facebook.presto.common.block.BlockBuilder in project presto by prestodb.
the class ByteEncoding 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 length = columnData.getLength(i);
if (length != 0) {
checkState(length == SIZE_OF_BYTE, "Bytes should be 1 byte");
type.writeLong(builder, slice.getByte(columnData.getOffset(i)));
} else {
builder.appendNull();
}
}
return builder.build();
}
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) {
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.common.block.BlockBuilder in project presto by prestodb.
the class FloatEncoding 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 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.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) {
builder.appendNull();
} else {
type.writeLong(builder, readVInt(slice, offset, length));
}
}
return builder.build();
}
Aggregations