use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class VarbinaryFunctions method toIEEE754Binary64.
@Description("encode value as a big endian varbinary according to IEEE 754 double-precision floating-point format")
@ScalarFunction("to_ieee754_64")
@SqlType(StandardTypes.VARBINARY)
public static Slice toIEEE754Binary64(@SqlType(StandardTypes.DOUBLE) double value) {
Slice slice = Slices.allocate(Double.BYTES);
slice.setLong(0, Long.reverseBytes(Double.doubleToLongBits(value)));
return slice;
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class VarbinaryFunctions method spookyHashV2_64.
@Description("compute SpookyHashV2 64-bit hash")
@ScalarFunction
@SqlType(StandardTypes.VARBINARY)
public static Slice spookyHashV2_64(@SqlType(StandardTypes.VARBINARY) Slice slice) {
Slice hash = Slices.allocate(Long.BYTES);
hash.setLong(0, Long.reverseBytes(SpookyHashV2.hash64(slice, 0, slice.length(), 0)));
return hash;
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class VarbinaryFunctions method toBigEndian64.
@Description("encode value as a 64-bit 2's complement big endian varbinary")
@ScalarFunction("to_big_endian_64")
@SqlType(StandardTypes.VARBINARY)
public static Slice toBigEndian64(@SqlType(StandardTypes.BIGINT) long value) {
Slice slice = Slices.allocate(Long.BYTES);
slice.setLong(0, Long.reverseBytes(value));
return slice;
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class VarbinaryFunctions method crc32.
@Description("compute CRC-32")
@ScalarFunction
@SqlType(StandardTypes.BIGINT)
public static long crc32(@SqlType(StandardTypes.VARBINARY) Slice slice) {
CRC32 crc32 = new CRC32();
crc32.update(slice.toByteBuffer());
return crc32.getValue();
}
use of io.prestosql.spi.function.Description in project hetu-core by openlookeng.
the class BingTileFunctions method bingTilesAround.
@Description("Given a (longitude, latitude) point, returns the surrounding Bing tiles at the specified zoom level")
@ScalarFunction("bing_tiles_around")
@SqlType("array(" + BingTileType.NAME + ")")
public static Block bingTilesAround(@SqlType(StandardTypes.DOUBLE) double latitude, @SqlType(StandardTypes.DOUBLE) double longitude, @SqlType(StandardTypes.INTEGER) long zoomLevel) {
checkLatitude(latitude, LATITUDE_OUT_OF_RANGE);
checkLongitude(longitude, LONGITUDE_OUT_OF_RANGE);
checkZoomLevel(zoomLevel);
long mapSize = mapSize(toIntExact(zoomLevel));
long maxTileIndex = (mapSize / TILE_PIXELS) - 1;
int tileX = longitudeToTileX(longitude, mapSize);
int tileY = longitudeToTileY(latitude, mapSize);
BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, 9);
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
int x = tileX + i;
int y = tileY + j;
if (x >= 0 && x <= maxTileIndex && y >= 0 && y <= maxTileIndex) {
BIGINT.writeLong(blockBuilder, BingTile.fromCoordinates(x, y, toIntExact(zoomLevel)).encode());
}
}
}
return blockBuilder.build();
}
Aggregations