Search in sources :

Example 51 with Description

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;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 52 with Description

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;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 53 with Description

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;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 54 with Description

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();
}
Also used : CRC32(java.util.zip.CRC32) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Example 55 with Description

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();
}
Also used : Point(com.esri.core.geometry.Point) GeometryUtils.disjoint(io.prestosql.geospatial.GeometryUtils.disjoint) BlockBuilder(io.prestosql.spi.block.BlockBuilder) ScalarFunction(io.prestosql.spi.function.ScalarFunction) Description(io.prestosql.spi.function.Description) SqlType(io.prestosql.spi.function.SqlType)

Aggregations

Description (io.prestosql.spi.function.Description)76 ScalarFunction (io.prestosql.spi.function.ScalarFunction)76 SqlType (io.prestosql.spi.function.SqlType)76 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)40 SqlNullable (io.prestosql.spi.function.SqlNullable)34 Slice (io.airlift.slice.Slice)18 LiteralParameters (io.prestosql.spi.function.LiteralParameters)15 Point (com.esri.core.geometry.Point)14 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)14 Constraint (io.prestosql.type.Constraint)13 MultiPoint (com.esri.core.geometry.MultiPoint)12 BlockBuilder (io.prestosql.spi.block.BlockBuilder)11 PrestoException (io.prestosql.spi.PrestoException)10 SliceUtf8.lengthOfCodePoint (io.airlift.slice.SliceUtf8.lengthOfCodePoint)7 SliceUtf8.offsetOfCodePoint (io.airlift.slice.SliceUtf8.offsetOfCodePoint)7 GeometryType (io.prestosql.geospatial.GeometryType)6 Envelope (com.esri.core.geometry.Envelope)5 MultiPath (com.esri.core.geometry.MultiPath)5 Matcher (io.airlift.joni.Matcher)5 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)5