Hello everyone,
I am looking into the new spatial-indexer feature that came with Jena
Fuseki 5.5.0.

The spatial index is regenerated without any issue but it seems I need to
restart Jena Fuseki for the index to be reloaded. Does anyone have
experience using it ? Is it expected ?
This would not be a big issue though, the restart is quite fast since the
big indexing job can be done asynchronously instead of during startup.

I followed the steps documented here :
https://github.com/apache/jena-site/pull/213

And attached below the config.ttl and relevant excerpts from the logs if
needed.

What I found looking through the PR :
https://github.com/apache/jena/pull/3027
The module does call buildSpatialIndexTree through
SpatialIndexerComputation.java
<https://github.com/apache/jena/blob/cc16f8569bbd2a68b2b088bdae2c0777482bd312/jena-geosparql/src/main/java/org/apache/jena/geosparql/spatial/index/v2/SpatialIndexerComputation.java#L109>
Which is also the same that does Jena Fuseki on startup through
SpatialIndexLib.java
<https://github.com/apache/jena/blob/cc16f8569bbd2a68b2b088bdae2c0777482bd312/jena-geosparql/src/main/java/org/apache/jena/geosparql/spatial/index/v2/SpatialIndexLib.java#L202>
However, in the latter, there is a call to setSpatialIndex
<https://github.com/apache/jena/blob/cc16f8569bbd2a68b2b088bdae2c0777482bd312/jena-geosparql/src/main/java/org/apache/jena/geosparql/spatial/index/v2/SpatialIndexLib.java#L209>
after the build which is not done in the former.

I'm still learning about the features of Jena Fuseki so maybe I
went overboard looking through the code.

Kind regards,

---config.ttl---
PREFIX fuseki:    <http://jena.apache.org/fuseki#>
PREFIX rdf:       <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:      <http://www.w3.org/2000/01/rdf-schema#>
PREFIX tdb2:      <http://jena.apache.org/2016/tdb#>
PREFIX ja:        <http://jena.hpl.hp.com/2005/11/Assembler#>
PREFIX geosparql: <http://jena.apache.org/geosparql#>

<#service> rdf:type fuseki:Service;
    fuseki:name "geo";

    fuseki:endpoint [ fuseki:operation fuseki:query ; fuseki:name "query" ];
    fuseki:endpoint [ fuseki:operation fuseki:update ; fuseki:name "update"
];
    fuseki:endpoint [ fuseki:operation fuseki:gsp-r ; fuseki:name "get" ];
    fuseki:endpoint [ fuseki:operation fuseki:gsp-rw ; fuseki:name "data" ];
    fuseki:endpoint [ fuseki:operation fuseki:upload ; fuseki:name "upload"
];
    fuseki:endpoint [ fuseki:operation fuseki:spatial-indexer ; fuseki:name
"spatial-indexer" ] ;
    fuseki:dataset <#geo_ds> .

<#geo_ds> rdf:type geosparql:geosparqlDataset ;
    geosparql:spatialIndexFile     "databases/spatial.index";
    geosparql:srsUri               <
http://www.opengis.net/def/crs/OGC/1.3/CRS84> ;
    geosparql:inference            true ;
    geosparql:queryRewrite         true ;
    geosparql:indexEnabled         true ;
    geosparql:applyDefaultGeometry false ;
    geosparql:indexSizes           "-1,-1,-1" ;       # Default - unlimited.
    geosparql:indexExpires         "5000,5000,5000" ; # Default - time in
milliseconds.
    geosparql:dataset <#baseDataset> ;
    .

<#baseDataset> rdf:type tdb2:DatasetTDB2 ;
    tdb2:location "databases/geo" ;
    .
---

---log on first boot---
18:40:30 INFO  Server          :: Module: Spatial Indexer (5.5.0)
18:40:30 INFO  Server          :: Apache Jena Fuseki 5.5.0
18:40:30 INFO  Config          :: Fuseki Base = /fuseki
18:40:30 INFO  Config          :: Load configuration:
file:///fuseki/configuration/config.ttl
18:40:30 INFO  GeoSPARQLOperations :: Applying GeoSPARQL Schema - Started
18:40:30 INFO  GeoSPARQLOperations :: GeoSPARQL schema not applied to empty
graph: default
18:40:30 INFO  GeoSPARQLOperations :: Applying GeoSPARQL Schema - Completed
18:40:30 WARN  GeoAssembler    :: Dataset is empty. Constructing an empty
spatial index that needs to be updated once data is added.
18:40:30 INFO  SpatialIndexLib :: Building Spatial Index - Started
18:40:30 INFO  SpatialIndexLib :: Building Spatial Index - Completed
18:40:30 INFO  SpatialIndexIoKryo :: Saving Spatial Index - Started:
/jena-fuseki/databases/spatial.index
18:40:30 INFO  SpatialIndexIoKryo :: Saving Spatial Index - Success:
/jena-fuseki/databases/spatial.index
...
18:40:31 INFO  Server          :: Start Fuseki (http=3030)
---

--log of the spatial-indexer call---
18:44:36 INFO  Fuseki          :: [33] POST
http://localhost:3031/mcc/spatial-indexer
18:44:36 INFO  Fuseki          :: [33] spatial index: computation request
accepted.
18:44:36 INFO  Fuseki          :: [33] 200 OK (10 ms)
18:44:36 INFO  SpatialIndexLib :: Indexing of 1 graphs started. A prior
index will be UPDATED with the newly indexed graphs.
18:44:36 INFO  SpatialIndexLib :: Writing spatial index of 1 graphs to disk
at path /jena-fuseki/databases/spatial.index
18:44:36 INFO  SpatialIndexIoKryo :: Saving Spatial Index - Started:
/jena-fuseki/databases/spatial.index
18:44:36 INFO  SpatialIndexIoKryo :: Saving Spatial Index - Success:
/jena-fuseki/databases/spatial.index
18:44:36 INFO  SpatialIndexLib :: Indexing of 1 graphs completed
successfully.
18:44:36 INFO  SpatialIndexerService :: Indexing task of 1 graphs
terminated.
---

--log after restart---
19:10:04 INFO  Server          :: Module: Spatial Indexer (5.5.0)
19:10:04 INFO  Server          :: Apache Jena Fuseki 5.5.0
19:10:04 INFO  Config          :: Fuseki Base = /fuseki
19:10:05 INFO  Config          :: Load configuration:
file:///fuseki/configuration/config.ttl
19:10:05 INFO  GeoSPARQLOperations :: Applying GeoSPARQL Schema - Started
19:10:05 INFO  GeoSPARQLOperations :: GeoSPARQL schema applied to graph:
default
19:10:05 INFO  GeoSPARQLOperations :: Applying GeoSPARQL Schema - Completed
19:10:05 INFO  SpatialIndexIoKryo :: Loading Spatial Index - Started:
/jena-fuseki/databases/spatial.index
19:10:05 INFO  SpatialIndexIoKryo :: Loading Spatial Index - Completed:
/jena-fuseki/databases/spatial.index
...
19:10:06 INFO  Server          :: Start Fuseki (http=3030)
---

Evans Bernier

Reply via email to