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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations