Skip to content

Commit 119c154

Browse files
authored
GEOMESA-3579 Trino - Add SpaceFillingCurves Java-interop (#3580)
1 parent c72cf32 commit 119c154

8 files changed

Lines changed: 328 additions & 196 deletions

File tree

geomesa-trino/geomesa-trino-plugin/pom.xml

Lines changed: 54 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@
5959
<groupId>org.locationtech.jts</groupId>
6060
<artifactId>jts-core</artifactId>
6161
</dependency>
62-
<dependency>
63-
<groupId>org.scala-lang</groupId>
64-
<artifactId>scala-library</artifactId>
65-
</dependency>
6662
<dependency>
6763
<groupId>org.locationtech.geomesa</groupId>
6864
<artifactId>geomesa-z3_${scala.binary.version}</artifactId>
@@ -144,6 +140,18 @@
144140
</dependencies>
145141

146142
<build>
143+
<pluginManagement>
144+
<plugins>
145+
<plugin>
146+
<groupId>net.alchim31.maven</groupId>
147+
<artifactId>scala-maven-plugin</artifactId>
148+
<configuration>
149+
<skip>true</skip>
150+
</configuration>
151+
</plugin>
152+
</plugins>
153+
</pluginManagement>
154+
147155
<plugins>
148156
<!-- This is the only geomesa-trino module that must compile against Trino's
149157
Java-25 bytecode (trino-spi / trino-iceberg), so enforces a JDK-25 toolchain
@@ -169,34 +177,6 @@
169177
</execution>
170178
</executions>
171179
</plugin>
172-
<plugin>
173-
<groupId>net.alchim31.maven</groupId>
174-
<artifactId>scala-maven-plugin</artifactId>
175-
<configuration>
176-
<scalaVersion>${scala.version}</scalaVersion>
177-
<scalaCompatVersion>${scala.binary.version}</scalaCompatVersion>
178-
<source>${jdk.version}</source>
179-
<target>${jdk.version}</target>
180-
<sendJavaToScalac>false</sendJavaToScalac>
181-
</configuration>
182-
<executions>
183-
<execution>
184-
<id>scala-compile-first</id>
185-
<phase>process-resources</phase>
186-
<goals>
187-
<goal>add-source</goal>
188-
<goal>compile</goal>
189-
</goals>
190-
</execution>
191-
<execution>
192-
<id>scala-test-compile</id>
193-
<phase>process-test-resources</phase>
194-
<goals>
195-
<goal>testCompile</goal>
196-
</goals>
197-
</execution>
198-
</executions>
199-
</plugin>
200180
<plugin>
201181
<groupId>org.apache.maven.plugins</groupId>
202182
<artifactId>maven-shade-plugin</artifactId>
@@ -237,4 +217,46 @@
237217
</plugin>
238218
</plugins>
239219
</build>
220+
221+
<profiles>
222+
<profile>
223+
<id>release</id>
224+
<build>
225+
<plugins>
226+
<!-- since no scala, have to use the regular javadoc plugin -->
227+
<plugin>
228+
<groupId>org.apache.maven.plugins</groupId>
229+
<artifactId>maven-javadoc-plugin</artifactId>
230+
<executions>
231+
<execution>
232+
<id>attach-javadocs</id>
233+
<goals>
234+
<goal>jar</goal>
235+
</goals>
236+
</execution>
237+
</executions>
238+
</plugin>
239+
<plugin>
240+
<groupId>org.apache.maven.plugins</groupId>
241+
<artifactId>maven-dependency-plugin</artifactId>
242+
<!-- required to build site javadocs with mixed scala sources -->
243+
<executions>
244+
<execution>
245+
<id>generate-classpath</id>
246+
<phase>generate-sources</phase>
247+
<goals>
248+
<goal>build-classpath</goal>
249+
</goals>
250+
<configuration>
251+
<outputFile>${project.build.directory}/module-classpath</outputFile>
252+
<outputProperty>dep.cp</outputProperty>
253+
</configuration>
254+
</execution>
255+
</executions>
256+
</plugin>
257+
</plugins>
258+
</build>
259+
</profile>
260+
</profiles>
261+
240262
</project>

geomesa-trino/geomesa-trino-plugin/src/main/java/org/locationtech/geomesa/trino/spatial/iceberg/connector/SpatialConnectorMetadata.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.trino.spi.type.RealType;
3030
import io.trino.spi.type.RowType;
3131
import io.trino.spi.type.VarcharType;
32+
import org.locationtech.geomesa.curve.interop.SpaceFillingCurves.HexRange;
3233
import org.locationtech.geomesa.trino.spatial.iceberg.transforms.SpatialIndexRanges;
3334
import org.locationtech.geomesa.trino.spatial.iceberg.BboxHandles;
3435
import org.locationtech.geomesa.trino.spatial.iceberg.GeoMesaColumnCatalog;
@@ -243,16 +244,16 @@ public Optional<ConstraintApplicationResult<ConnectorTableHandle>> applyFilter(
243244
private static List<Range> buildPartitionRanges(SpatialPartitionHandle sp, List<Envelope> envelopes) {
244245
List<Range> ranges = new ArrayList<>();
245246
for (Envelope env : envelopes) {
246-
List<String[]> hexRanges = switch (sp.kind()) {
247+
List<HexRange> hexRanges = switch (sp.kind()) {
247248
case Z2 -> SpatialIndexRanges.z2Ranges(env);
248249
case XZ2 -> SpatialIndexRanges.xz2Ranges(env);
249250
};
250-
for (String[] r : hexRanges) {
251-
if (r[0].equals(r[1])) {
252-
ranges.add(Range.equal(VarcharType.VARCHAR, Slices.utf8Slice(r[0])));
251+
for (HexRange r : hexRanges) {
252+
if (r.lower().equals(r.upper())) {
253+
ranges.add(Range.equal(VarcharType.VARCHAR, Slices.utf8Slice(r.lower())));
253254
} else {
254255
ranges.add(Range.range(VarcharType.VARCHAR,
255-
Slices.utf8Slice(r[0]), true, Slices.utf8Slice(r[1]), true));
256+
Slices.utf8Slice(r.lower()), true, Slices.utf8Slice(r.upper()), true));
256257
}
257258
}
258259
}

geomesa-trino/geomesa-trino-plugin/src/main/java/org/locationtech/geomesa/trino/spatial/iceberg/transforms/SpatialIndexRanges.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88

99
package org.locationtech.geomesa.trino.spatial.iceberg.transforms;
1010

11+
import org.locationtech.geomesa.curve.interop.SpaceFillingCurves;
12+
import org.locationtech.geomesa.curve.interop.SpaceFillingCurves.HexRange;
1113
import org.locationtech.jts.geom.Envelope;
1214

13-
import java.util.Arrays;
1415
import java.util.List;
1516

1617
/**
17-
* Hex-encoded Z2/XZ2 index ranges covering a query envelope, for pushdown
18+
* Hex-encoded Z2/XZ2 index ranges covering a JTS query envelope, for pushdown
1819
* against hex-partitioned storage columns ({@code __<X>_z2__} /
1920
* {@code __<X>_xz2__}).
2021
*
2122
* <p>Endpoints are encoded with {@code Z2SFC.hexEncode}/{@code XZ2SFC.hexEncode}
22-
* (via {@link SfcBridge}), which left-align the significant bits so
23+
* (via {@link SpaceFillingCurves}), which left-align the significant bits so
2324
* lexicographic comparison over the fixed-width strings matches numeric
2425
* comparison of the underlying index values. That makes the inclusive
25-
* {@code [lo, hi]} string ranges directly usable both as VARCHAR domains on
26+
* {@code [lo, hi]} ranges directly usable both as VARCHAR domains on
2627
* the full column value and — because prefix order is preserved — under
2728
* Iceberg {@code truncate(width)} partition projection at any width.
2829
*/
@@ -41,26 +42,26 @@ public final class SpatialIndexRanges {
4142
private SpatialIndexRanges() {}
4243

4344
/**
44-
* Z2 index ranges covering the query envelope, hex-encoded for pushdown
45+
* Z2 index ranges covering a JTS query envelope, hex-encoded for pushdown
4546
* against a {@code __<X>_z2__} column.
4647
*
4748
* @param env query envelope in WGS84 lon/lat
48-
* @return inclusive {@code [lo, hi]} hex ranges
49+
* @return inclusive hex ranges
4950
*/
50-
public static List<String[]> z2Ranges(Envelope env) {
51-
return Arrays.asList(SfcBridge.z2HexRanges(
52-
env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), MAX_RANGES));
51+
public static List<HexRange> z2Ranges(Envelope env) {
52+
return SpaceFillingCurves.z2HexRanges(
53+
env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), MAX_RANGES);
5354
}
5455

5556
/**
56-
* XZ2 index ranges covering the query envelope at {@link #G}, hex-encoded
57+
* XZ2 index ranges covering a JTS query envelope at {@link #G}, hex-encoded
5758
* for pushdown against a {@code __<X>_xz2__} column.
5859
*
5960
* @param env query envelope in WGS84 lon/lat
60-
* @return inclusive {@code [lo, hi]} hex ranges
61+
* @return inclusive hex ranges
6162
*/
62-
public static List<String[]> xz2Ranges(Envelope env) {
63-
return Arrays.asList(SfcBridge.xz2HexRanges(
64-
env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), G, MAX_RANGES));
63+
public static List<HexRange> xz2Ranges(Envelope env) {
64+
return SpaceFillingCurves.xz2HexRanges(
65+
env.getMinX(), env.getMinY(), env.getMaxX(), env.getMaxY(), G, MAX_RANGES);
6566
}
6667
}

geomesa-trino/geomesa-trino-plugin/src/main/scala/org/locationtech/geomesa/trino/spatial/iceberg/transforms/SfcBridge.scala

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)