Skip to content

Commit

Permalink
Merge branch 'update-22.0.x' into update-22.1.x
Browse files Browse the repository at this point in the history
# Conflicts:
#	pom.xml
#	src/main/java/org/sheinbergon/dremio/udf/gis/STBuffer.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STBufferParameters.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STCentroid.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STCollectAggregate.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STConvexHull.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STEnvelope.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeomFromEWKT.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeomFromText.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeomFromTextSrid.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeomFromWKB.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeomFromWKBSrid.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STGeometryN.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STIsClosed.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STIsCollection.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STIsEmpty.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/STUnionAggregate.java
#	src/main/java/org/sheinbergon/dremio/udf/gis/util/GeometryHelpers.java
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STAsEWKTTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STBufferParametersTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STCollectAggregateTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STConvexHullTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STGeomFromEWKTTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/STUnionAggregateTests.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/spec/GeometryAggregationFunSpec.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/spec/GeometryOutputFunSpec.kt
#	src/test/kotlin/org/sheinbergon/dremio/udf/gis/spec/GeometryProcessingFunSpec.kt
  • Loading branch information
sheinbergon committed Jan 28, 2023
2 parents e21f07d + f197363 commit 7619a11
Show file tree
Hide file tree
Showing 78 changed files with 1,161 additions and 242 deletions.
21 changes: 14 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<carrotsearch.version>0.7.0</carrotsearch.version>
<arrow-memory-netty.version>8.0.0</arrow-memory-netty.version>
</properties>
<version>0.6.4${artifact.version.suffix}</version>
<version>0.6.6${artifact.version.suffix}</version>
<name>dremio-udf-gis</name>
<description>GIS UDF extensions for Dremio</description>
<url>https://github.com/sheinbergon/dremio-udf-gis</url>
Expand Down Expand Up @@ -72,6 +72,19 @@
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dremio.sabot</groupId>
<artifactId>dremio-sabot-vector-tools</artifactId>
<version>${dremio.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.dremio.sabot</groupId>
<artifactId>dremio-sabot-logical</artifactId>
Expand Down Expand Up @@ -160,12 +173,6 @@
<version>${commons-io.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
<scope>provided</scope>
</dependency>
<!-- Test Dependencies -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAngle2Lines.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,31 @@
@FunctionTemplate(
name = "ST_Angle",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAngle2Lines implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput1;
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput2;

@Output
org.apache.arrow.vector.holders.Float8Holder output;
org.apache.arrow.vector.holders.NullableFloat8Holder output;

public void setup() {
}

public void eval() {
org.locationtech.jts.geom.LineString l1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toLineString(binaryInput1);
org.locationtech.jts.geom.LineString l2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toLineString(binaryInput2);
output.value = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(
l1.getStartPoint(),
l1.getEndPoint(),
l2.getStartPoint(),
l2.getEndPoint()
);
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.areHoldersSet(binaryInput1, binaryInput2)) {
org.locationtech.jts.geom.LineString l1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toLineString(binaryInput1);
org.locationtech.jts.geom.LineString l2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toLineString(binaryInput2);
double radians = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(
l1.getStartPoint(),
l1.getEndPoint(),
l2.getStartPoint(),
l2.getEndPoint()
);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.setDoubleValue(output, radians);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(output);
}
}
}
18 changes: 11 additions & 7 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAngle3Points.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,29 @@
@FunctionTemplate(
name = "ST_Angle",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAngle3Points implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput1;
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput2;
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput3;

@Output
org.apache.arrow.vector.holders.Float8Holder output;
org.apache.arrow.vector.holders.NullableFloat8Holder output;

public void setup() {
}

public void eval() {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
org.locationtech.jts.geom.Point p3 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput3);
output.value = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(p2, p1, p2, p3);
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.areHoldersSet(binaryInput1, binaryInput2, binaryInput3)) {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
org.locationtech.jts.geom.Point p3 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput3);
double radians = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(p2, p1, p2, p3);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.setDoubleValue(output, radians);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(output);
}
}
}
20 changes: 12 additions & 8 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAngle4Points.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@FunctionTemplate(
name = "ST_Angle",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAngle4Points implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput1;
Expand All @@ -35,18 +35,22 @@ public class STAngle4Points implements SimpleFunction {
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput3;
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput4;

@Output
org.apache.arrow.vector.holders.Float8Holder output;
org.apache.arrow.vector.holders.NullableFloat8Holder output;

public void setup() {
}

public void eval() {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
org.locationtech.jts.geom.Point p3 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput3);
org.locationtech.jts.geom.Point p4 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput4);
output.value = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(p1, p2, p3, p4);
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.areHoldersSet(binaryInput1, binaryInput2, binaryInput3, binaryInput4)) {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
org.locationtech.jts.geom.Point p3 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput3);
org.locationtech.jts.geom.Point p4 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput4);
double radians = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAngleRadians(p1, p2, p3, p4);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.setDoubleValue(output, radians);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(output);
}
}
}
13 changes: 9 additions & 4 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@
@FunctionTemplate(
name = "ST_Area",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL,
costCategory = FunctionTemplate.FunctionCostCategory.MEDIUM)
public class STArea implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput;

@Output
org.apache.arrow.vector.holders.Float8Holder output;
org.apache.arrow.vector.holders.NullableFloat8Holder output;

public void setup() {
}

public void eval() {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
output.value = geom.getArea();
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.isHolderSet(binaryInput)) {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.setDoubleValue(output, geom.getArea());
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(output);
}
}
}
55 changes: 55 additions & 0 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAsBinary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sheinbergon.dremio.udf.gis;

import com.dremio.exec.expr.SimpleFunction;
import com.dremio.exec.expr.annotations.FunctionTemplate;
import com.dremio.exec.expr.annotations.Output;
import com.dremio.exec.expr.annotations.Param;

import javax.inject.Inject;

@FunctionTemplate(
name = "ST_AsBinary",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAsBinary implements SimpleFunction {

@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput;

@Output
org.apache.arrow.vector.holders.NullableVarBinaryHolder wkbOutput;

@Inject
org.apache.arrow.memory.ArrowBuf buffer;

public void setup() {
}

public void eval() {
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.isHolderSet(binaryInput)) {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
byte[] bytes = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toBinary(geom);
buffer = buffer.reallocIfNeeded(bytes.length);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.populate(bytes, buffer, wkbOutput);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(wkbOutput);
}
}
}
55 changes: 55 additions & 0 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAsEWKB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sheinbergon.dremio.udf.gis;

import com.dremio.exec.expr.SimpleFunction;
import com.dremio.exec.expr.annotations.FunctionTemplate;
import com.dremio.exec.expr.annotations.Output;
import com.dremio.exec.expr.annotations.Param;

import javax.inject.Inject;

@FunctionTemplate(
name = "ST_AsEWKB",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAsEWKB implements SimpleFunction {

@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput;

@Output
org.apache.arrow.vector.holders.NullableVarBinaryHolder ewkbOutput;

@Inject
org.apache.arrow.memory.ArrowBuf buffer;

public void setup() {
}

public void eval() {
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.isHolderSet(binaryInput)) {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
byte[] bytes = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toEWKB(geom);
buffer = buffer.reallocIfNeeded(bytes.length);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.populate(bytes, buffer, ewkbOutput);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(ewkbOutput);
}
}
}
15 changes: 10 additions & 5 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STAzimuth.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,26 @@
@FunctionTemplate(
name = "ST_Azimuth",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL)
public class STAzimuth implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput1;
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput2;
@Output
org.apache.arrow.vector.holders.Float8Holder output;
org.apache.arrow.vector.holders.NullableFloat8Holder output;

public void setup() {
}

public void eval() {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
output.value = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAzimuthRadians(p1, p2);
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.areHoldersSet(binaryInput1, binaryInput2)) {
org.locationtech.jts.geom.Point p1 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput1);
org.locationtech.jts.geom.Point p2 = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toPoint(binaryInput2);
double radians = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toAzimuthRadians(p1, p2);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.setDoubleValue(output, radians);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(output);
}
}
}
19 changes: 11 additions & 8 deletions src/main/java/org/sheinbergon/dremio/udf/gis/STBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@
import com.dremio.exec.expr.annotations.Param;
import org.apache.arrow.memory.ArrowBuf;



import javax.inject.Inject;

@FunctionTemplate(
name = "ST_Buffer",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
nulls = FunctionTemplate.NullHandling.INTERNAL,
costCategory = FunctionTemplate.FunctionCostCategory.MEDIUM)
public class STBuffer implements SimpleFunction {
@Param
org.apache.arrow.vector.holders.NullableVarBinaryHolder binaryInput;
Expand All @@ -48,10 +47,14 @@ public void setup() {
}

public void eval() {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
org.locationtech.jts.geom.Geometry buffered = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.buffer(geom, radiusInput.value, null);
byte[] bytes = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toBinary(buffered);
buffer = buffer.reallocIfNeeded(bytes.length);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.populate(bytes, buffer, binaryOutput);
if (org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.isHolderSet(binaryInput)) {
org.locationtech.jts.geom.Geometry geom = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toGeometry(binaryInput);
org.locationtech.jts.geom.Geometry buffered = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.buffer(geom, radiusInput.value, null);
byte[] bytes = org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.toEWKB(buffered);
buffer = buffer.reallocIfNeeded(bytes.length);
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.populate(bytes, buffer, binaryOutput);
} else {
org.sheinbergon.dremio.udf.gis.util.GeometryHelpers.markHolderNotSet(binaryOutput);
}
}
}
Loading

0 comments on commit 7619a11

Please sign in to comment.