Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jena-geosparql - Add assembler option to disable spatial index #1344

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public DatasetGraph createDataset(Assembler a, Resource root) {
if (root.hasProperty(pSpatialIndexFile) )
spatialIndexFilename = GraphUtils.getStringValue(root, pSpatialIndexFile);

// Spatial Index enabled.
boolean spatialIndexEnabled = true;
if (root.hasProperty(pSpatialIndexEnabled) )
spatialIndexEnabled = getBooleanValue(root, pSpatialIndexEnabled);

// ---- Build

Dataset dataset = DatasetFactory.wrap(base);
Expand Down Expand Up @@ -148,7 +153,7 @@ public DatasetGraph createDataset(Assembler a, Resource root) {
GeoSPARQLConfig.setupNoIndex(queryRewrite);
}

prepareSpatialExtension(dataset, spatialIndexFilename);
prepareSpatialExtension(dataset, spatialIndexEnabled, spatialIndexFilename);
return base;
}

Expand All @@ -165,13 +170,13 @@ private static List<Integer> getListInteger(Resource r, Property p, int len) {
return integerList;
}

private static void prepareSpatialExtension(Dataset dataset, String spatialIndex){
private static void prepareSpatialExtension(Dataset dataset, boolean spatialIndexEnabled, String spatialIndex){
boolean isEmpty = dataset.calculate(()->dataset.isEmpty());
if ( isEmpty && spatialIndex != null ) {
if ( isEmpty && spatialIndexEnabled && spatialIndex != null ) {
LOG.warn("Dataset empty. Spatial Index not constructed. Server will require restarting after adding data and any updates to build Spatial Index.");
return;
}
if ( isEmpty )
if ( isEmpty || !spatialIndexEnabled )
// Nothing to do.
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ private static Property property(String shortName) {
// "File to load or store the spatial index. Default to " + SPATIAL_INDEX_FILE + " in TDB folder if using TDB and not set. Otherwise spatial index is not stored.
public static final Property pSpatialIndexFile = property("spatialIndexFile");

// Whether to load/generate the spatial index at all (defaults to True). With this off, the value of spatialIndexFile will be ignored.
public static final Property pSpatialIndexEnabled = property("spatialIndexEnabled");

// Dataset
public static final Property pDataset = property("dataset");
}