use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class ArrayIntersectFunction method intersect.
@ScalarFunction("array_intersect")
@Description("Intersects elements of the two given arrays")
@TypeParameter("E")
@SqlType("array(E)")
public static Block intersect(@TypeParameter("E") Type type, @SqlType("array(E)") Block leftArray, @SqlType("array(E)") Block rightArray) {
if (leftArray.getPositionCount() < rightArray.getPositionCount()) {
Block tempArray = leftArray;
leftArray = rightArray;
rightArray = tempArray;
}
int rightPositionCount = rightArray.getPositionCount();
if (rightPositionCount == 0) {
return rightArray;
}
OptimizedTypedSet typedSet = new OptimizedTypedSet(type, rightPositionCount);
typedSet.union(rightArray);
typedSet.intersect(leftArray);
return typedSet.getBlock();
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class BingTileFunctions method bingTileChildren.
@Description("Return the children for a Bing tile")
@ScalarFunction("bing_tile_children")
@SqlType("array(" + BingTileType.NAME + ")")
public static Block bingTileChildren(@SqlType(BingTileType.NAME) long input) {
BingTile tile = BingTile.decode(input);
try {
List<BingTile> children = tile.findChildren();
BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, children.size());
children.stream().forEach(child -> BIGINT.writeLong(blockBuilder, child.encode()));
return blockBuilder.build();
} catch (IllegalArgumentException e) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, e.getMessage(), e);
}
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stExteriorRing.
@SqlNullable
@Description("Returns a line string representing the exterior ring of the POLYGON")
@ScalarFunction("ST_ExteriorRing")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stExteriorRing(@SqlType(GEOMETRY_TYPE_NAME) Slice input) {
Geometry geometry = deserialize(input);
validateType("ST_ExteriorRing", geometry, EnumSet.of(POLYGON));
if (geometry.isEmpty()) {
return null;
}
return serialize(((org.locationtech.jts.geom.Polygon) geometry).getExteriorRing());
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stSymmetricDifference.
@Description("Returns the Geometry value that represents the point set symmetric difference of two Geometries")
@ScalarFunction("ST_SymDifference")
@SqlType(GEOMETRY_TYPE_NAME)
public static Slice stSymmetricDifference(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return EsriGeometrySerde.serialize(leftGeometry.symDifference(rightGeometry));
}
use of com.facebook.presto.spi.function.Description in project presto by prestodb.
the class GeoFunctions method stEquals.
@SqlNullable
@Description("Returns TRUE if the given geometries represent the same geometry")
@ScalarFunction("ST_Equals")
@SqlType(BOOLEAN)
public static Boolean stEquals(@SqlType(GEOMETRY_TYPE_NAME) Slice left, @SqlType(GEOMETRY_TYPE_NAME) Slice right) {
OGCGeometry leftGeometry = EsriGeometrySerde.deserialize(left);
OGCGeometry rightGeometry = EsriGeometrySerde.deserialize(right);
verifySameSpatialReference(leftGeometry, rightGeometry);
return leftGeometry.Equals(rightGeometry);
}
Aggregations