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