use of com.facebook.presto.annotation.UsedByGeneratedCode in project presto by prestodb.
the class RowHashCodeOperator method hash.
@UsedByGeneratedCode
public static long hash(Type rowType, Block block) {
BlockBuilder blockBuilder = rowType.createBlockBuilder(new BlockBuilderStatus(), 1);
blockBuilder.writeObject(block).closeEntry();
return rowType.hash(blockBuilder.build(), 0);
}
use of com.facebook.presto.annotation.UsedByGeneratedCode in project presto by prestodb.
the class MapConstructor method createMap.
@UsedByGeneratedCode
public static Block createMap(MapType mapType, Block keyBlock, Block valueBlock) {
BlockBuilder blockBuilder = new InterleavedBlockBuilder(mapType.getTypeParameters(), new BlockBuilderStatus(), keyBlock.getPositionCount() * 2);
checkCondition(keyBlock.getPositionCount() == valueBlock.getPositionCount(), INVALID_FUNCTION_ARGUMENT, "Key and value arrays must be the same length");
for (int i = 0; i < keyBlock.getPositionCount(); i++) {
if (keyBlock.isNull(i)) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "map key cannot be null");
}
mapType.getKeyType().appendTo(keyBlock, i, blockBuilder);
mapType.getValueType().appendTo(valueBlock, i, blockBuilder);
}
return blockBuilder.build();
}
use of com.facebook.presto.annotation.UsedByGeneratedCode in project presto by prestodb.
the class DecimalCasts method doubleToShortDecimal.
@UsedByGeneratedCode
public static long doubleToShortDecimal(double value, long precision, long scale, long tenToScale) {
// TODO: implement specialized version for short decimals
Slice decimal = internalDoubleToLongDecimal(value, precision, scale);
long low = UnscaledDecimal128Arithmetic.getLong(decimal, 0);
long high = UnscaledDecimal128Arithmetic.getLong(decimal, 1);
checkState(high == 0 && low >= 0, "Unexpected long decimal");
if (UnscaledDecimal128Arithmetic.isNegative(decimal)) {
return -low;
} else {
return low;
}
}
use of com.facebook.presto.annotation.UsedByGeneratedCode in project presto by prestodb.
the class DecimalCasts method realToShortDecimal.
@UsedByGeneratedCode
public static long realToShortDecimal(long value, long precision, long scale, long tenToScale) {
// TODO: implement specialized version for short decimals
Slice decimal = realToLongDecimal(value, precision, scale);
long low = UnscaledDecimal128Arithmetic.getLong(decimal, 0);
long high = UnscaledDecimal128Arithmetic.getLong(decimal, 1);
checkState(high == 0 && low >= 0, "Unexpected long decimal");
if (UnscaledDecimal128Arithmetic.isNegative(decimal)) {
return -low;
} else {
return low;
}
}
use of com.facebook.presto.annotation.UsedByGeneratedCode in project presto by prestodb.
the class ArrayConcatUtils method appendElement.
@UsedByGeneratedCode
public static Block appendElement(Type elementType, Block block, Slice value) {
BlockBuilder blockBuilder = elementType.createBlockBuilder(new BlockBuilderStatus(), block.getPositionCount() + 1);
for (int i = 0; i < block.getPositionCount(); i++) {
elementType.appendTo(block, i, blockBuilder);
}
elementType.writeSlice(blockBuilder, value);
return blockBuilder.build();
}
Aggregations