You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2022/03/25 16:00:25 UTC
[jena] branch main updated: fix to load and register precomputed geospatial index properly
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
The following commit(s) were added to refs/heads/main by this push:
new 7da02c2 fix to load and register precomputed geospatial index properly
new 7168fc4 Merge pull request #1204 from LorenzBuehmann/bugfix/JENA-2289
7da02c2 is described below
commit 7da02c213e8d64f2923914d9b18a61fbe64f4ae2
Author: Lorenz Buehmann <bu...@informatik.uni-leipzig.de>
AuthorDate: Thu Feb 24 11:52:21 2022 +0100
fix to load and register precomputed geospatial index properly
---
.../org/apache/jena/geosparql/assembler/GeoAssembler.java | 9 ++++++++-
.../jena/geosparql/configuration/GeoSPARQLConfig.java | 13 +++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/assembler/GeoAssembler.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/assembler/GeoAssembler.java
index e620fb3..5eb53c2 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/assembler/GeoAssembler.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/assembler/GeoAssembler.java
@@ -176,14 +176,21 @@ public class GeoAssembler extends DatasetAssembler {
return;
try {
+ // no file given, i.e. in-memory index only
if ( spatialIndex == null ) {
GeoSPARQLConfig.setupSpatialIndex(dataset);
return;
}
+ // file given but empty -> compute and serialize index
Path spatialIndexPath = Path.of(spatialIndex);
- if ( ! Files.exists(spatialIndexPath) || Files.size(spatialIndexPath) == 0 )
+ if ( ! Files.exists(spatialIndexPath) || Files.size(spatialIndexPath) == 0 ) {
GeoSPARQLConfig.setupSpatialIndex(dataset, spatialIndexPath.toFile());
+ return;
+ }
+
+ // load and setup the precomputed index
+ GeoSPARQLConfig.setupPrecomputedSpatialIndex(dataset, spatialIndexPath.toFile());
}
catch (SrsException ex) {
// Data but no spatial data.
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
index 8549725..b08eb31 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
@@ -272,6 +272,19 @@ public class GeoSPARQLConfig {
}
/**
+ * Setup the precomputed Spatial Index using Dataset Dataset.<br>
+ * We assume that the spatial index was computed before and written to the given file.
+ *
+ * @param dataset the dataset
+ * @param spatialIndexFile the file containing the serialized spatial index
+ * @throws SpatialIndexException
+ */
+ public static final void setupPrecomputedSpatialIndex(Dataset dataset, File spatialIndexFile) throws SpatialIndexException {
+ SpatialIndex si = SpatialIndex.load(spatialIndexFile);
+ SpatialIndex.setSpatialIndex(dataset, si);
+ }
+
+ /**
* Setup Spatial Index using Dataset and most frequent SRS URI in
* Dataset.<br>
* Spatial Index written to file once created.