Search in sources :

Example 6 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class VarbinaryFunctions method toBigEndian32.

@Description("Encode value as a 32-bit 2's complement big endian varbinary")
@ScalarFunction("to_big_endian_32")
@SqlType(StandardTypes.VARBINARY)
public static Slice toBigEndian32(@SqlType(StandardTypes.INTEGER) long value) {
    Slice slice = Slices.allocate(Integer.BYTES);
    slice.setInt(0, Integer.reverseBytes((int) value));
    return slice;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Example 7 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class VarbinaryFunctions method spookyHashV2_32.

@Description("Compute SpookyHashV2 32-bit hash")
@ScalarFunction
@SqlType(StandardTypes.VARBINARY)
public static Slice spookyHashV2_32(@SqlType(StandardTypes.VARBINARY) Slice slice) {
    Slice hash = Slices.allocate(Integer.BYTES);
    hash.setInt(0, Integer.reverseBytes(SpookyHashV2.hash32(slice, 0, slice.length(), 0)));
    return hash;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Example 8 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class VarbinaryFunctions method toIEEE754Binary32.

@Description("Encode value as a big endian varbinary according to IEEE 754 single-precision floating-point format")
@ScalarFunction("to_ieee754_32")
@SqlType(StandardTypes.VARBINARY)
public static Slice toIEEE754Binary32(@SqlType(StandardTypes.REAL) long value) {
    Slice slice = Slices.allocate(Float.BYTES);
    slice.setInt(0, Integer.reverseBytes((int) value));
    return slice;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Example 9 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

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.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Example 10 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class VarbinaryFunctions method reverse.

@Description("Reverse a given varbinary")
@ScalarFunction("reverse")
@SqlType(StandardTypes.VARBINARY)
public static Slice reverse(@SqlType("varbinary") Slice inputSlice) {
    if (inputSlice.length() == 0) {
        return EMPTY_SLICE;
    }
    int length = inputSlice.length();
    Slice reverse = Slices.allocate(length);
    for (int i = 0; i < length; i++) {
        reverse.setByte(i, inputSlice.getByte((length - 1) - i));
    }
    return reverse;
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Aggregations

Description (io.trino.spi.function.Description)92 ScalarFunction (io.trino.spi.function.ScalarFunction)90 SqlType (io.trino.spi.function.SqlType)90 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)46 SqlNullable (io.trino.spi.function.SqlNullable)38 LiteralParameters (io.trino.spi.function.LiteralParameters)19 Constraint (io.trino.type.Constraint)18 Point (com.esri.core.geometry.Point)17 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)17 Slice (io.airlift.slice.Slice)17 BlockBuilder (io.trino.spi.block.BlockBuilder)16 MultiPoint (com.esri.core.geometry.MultiPoint)15 TrinoException (io.trino.spi.TrinoException)15 SliceUtf8.lengthOfCodePoint (io.airlift.slice.SliceUtf8.lengthOfCodePoint)8 SliceUtf8.offsetOfCodePoint (io.airlift.slice.SliceUtf8.offsetOfCodePoint)8 Matcher (io.airlift.joni.Matcher)7 GeometryType (io.trino.geospatial.GeometryType)7 Envelope (com.esri.core.geometry.Envelope)5 MultiPath (com.esri.core.geometry.MultiPath)5 MultiVertexGeometry (com.esri.core.geometry.MultiVertexGeometry)5