Skip to content
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
4 changes: 2 additions & 2 deletions jena-geosparql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
</dependency>

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo5</artifactId>
</dependency>

<!-- Non-free; testing only -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import org.locationtech.jts.geom.Envelope;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

public class EnvelopeSerializer extends Serializer<Envelope> {
@Override
Expand All @@ -35,7 +35,7 @@ public void write(Kryo kryo, Output output, Envelope envelope) {
}

@Override
public Envelope read(Kryo kryo, Input input, Class<Envelope> type) {
public Envelope read(Kryo kryo, Input input, Class<? extends Envelope> type) {
double xMin = input.readDouble();
double xMax = input.readDouble();
double yMin = input.readDouble();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.locationtech.jts.io.WKBReader;
import org.locationtech.jts.io.WKBWriter;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/** Geometry de-/serialization via the WKB facilities of JTS. */
public class GeometrySerializerJtsWkb
Expand Down Expand Up @@ -57,7 +57,7 @@ public void write(Kryo kryo, Output output, Geometry geometry) {
}

@Override
public Geometry read(Kryo kryo, Input input, Class<Geometry> type) {
public Geometry read(Kryo kryo, Input input, Class<? extends Geometry> type) {
byte[] bytes = kryo.readObject(input, byte[].class);
Geometry geometry;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/**
* An RDF 1.2 node serializer for kryo.
Expand Down Expand Up @@ -262,7 +262,7 @@ public void write(Kryo kryo, Output output, Node node) {
}

@Override
public Node read(Kryo kryo, Input input, Class<Node> cls) {
public Node read(Kryo kryo, Input input, Class<? extends Node> cls) {
Node result;
String v1, v2;
Triple t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import org.apache.jena.graph.Node;
import org.apache.jena.graph.Triple;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/** Kryo serializer for {@link Triple}. Depends on registered {@link Node} serializers. */
public class TripleSerializer extends Serializer<Triple> {
Expand All @@ -35,7 +35,7 @@ public void write(Kryo kryo, Output output, Triple obj) {
}

@Override
public Triple read(Kryo kryo, Input input, Class<Triple> objClass) {
public Triple read(Kryo kryo, Input input, Class<? extends Triple> objClass) {
Node s = (Node)kryo.readClassAndObject(input);
Node p = (Node)kryo.readClassAndObject(input);
Node o = (Node)kryo.readClassAndObject(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.jena.geosparql.kryo.EnvelopeSerializer;
import org.apache.jena.geosparql.kryo.NodeSerializer;
Expand All @@ -40,9 +41,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.serializers.MapSerializer;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.serializers.MapSerializer;

/**
* The class is used to configure the kryo serialization
Expand All @@ -58,10 +59,10 @@ public static void registerClasses(Kryo kryo, Serializer<Geometry> geometrySeria
LOGGER.debug("Registering kryo serializers for spatial index v2.");

// Java
Serializer<?> mapSerializer = new MapSerializer();
Serializer<?> mapSerializer = new MapSerializer<>();
kryo.register(Map.class, mapSerializer);
kryo.register(HashMap.class, mapSerializer);
kryo.register(LinkedHashMap.class, mapSerializer);
kryo.register(ConcurrentHashMap.class, mapSerializer);

// Jena
NodeSerializer.register(kryo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.apache.jena.graph.Node;
import org.locationtech.jts.index.strtree.STRtree;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

public class STRtreePerGraphSerializer
extends Serializer<STRtreePerGraph>
Expand All @@ -37,7 +37,7 @@ public void write(Kryo kryo, Output output, STRtreePerGraph index) {
}

@Override
public STRtreePerGraph read(Kryo kryo, Input input, Class<STRtreePerGraph> type) {
public STRtreePerGraph read(Kryo kryo, Input input, Class<? extends STRtreePerGraph> type) {
boolean isBuilt = input.readBoolean();
@SuppressWarnings("unchecked")
Map<Node, STRtree> treeMap = (Map<Node, STRtree>)kryo.readClassAndObject(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.jena.atlas.iterator.Iter;
import org.apache.jena.atlas.iterator.IteratorCloseable;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static STRtree buildSpatialIndexTree(Graph graph, String srsURI) throws S

// XXX This method overlaps function-wise with SpatialIndexerComputation. Consolidate?
public static STRtreePerGraph buildSpatialIndexTree(DatasetGraph datasetGraph, String srsURI) throws SpatialIndexException {
Map<Node, STRtree> treeMap = new LinkedHashMap<>();
Map<Node, STRtree> treeMap = new ConcurrentHashMap<>();

// Process default graph.
// LOGGER.info("building spatial index for default graph ...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
import java.util.Set;

import org.apache.jena.atlas.RuntimeIOException;
import org.apache.jena.atlas.io.IOX;
Expand All @@ -37,10 +38,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;
import com.google.gson.Gson;
import com.google.gson.JsonObject;

Expand All @@ -51,6 +52,12 @@ public class SpatialIndexIoKryo {
// The current version of the index only stores the envelopes so this feature is not needed.
private static boolean enableGeometrySerde = false;

/** Kryo4-based serialization is now obsolete. */
private static final Set<String> OBSOLETE_VERSIONS = Set.of("2.0.0");

/** The version of the index that is created by this class. */
public static final String VERSION = "3.0.0";

public static SpatialIndex loadOrBuildSpatialIndex(Dataset dataset, Path spatialIndexFile) throws SpatialIndexException {
SpatialIndex spatialIndex = loadOrBuildSpatialIndex(dataset, null, spatialIndexFile);
return spatialIndex;
Expand Down Expand Up @@ -149,7 +156,7 @@ public static final void save(Path spatialIndexFile, SpatialIndexPerGraph index)
public static void writeToOutputStream(OutputStream os, SpatialIndexPerGraph index) {
SpatialIndexHeader header = new SpatialIndexHeader();
header.setType(SpatialIndexHeader.TYPE_VALUE);
header.setVersion("2.0.0");
header.setVersion(VERSION);
header.setSrsUri(index.getSrsInfo().getSrsURI());

GeometrySerializerJtsWkb geometrySerializer = null;
Expand Down Expand Up @@ -207,8 +214,12 @@ public static final SpatialIndexPerGraph load(Path spatialIndexFile) throws Spat
}

String version = header.getVersion();
if (!"2.0.0".equals(version)) {
throw new SpatialIndexException("The version of the spatial index does not match the version of this loader class.");
if (!VERSION.equals(version)) {
if (OBSOLETE_VERSIONS.contains(version)) {
throw new SpatialIndexException("Spatial index version " + version + " is no longer supported. Move or delete this file to allow for creation of a new index in its place: " + spatialIndexFile);
} else {
throw new SpatialIndexException("Spatial index version " + version + " is not supported (expected version: " + VERSION + "). Offending file: " + spatialIndexFile);
}
}

srsUri = header.getSrsUri();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@

import org.locationtech.jts.geom.Envelope;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/*
* This file is an adapted copy of org.locationtech.jts.index.strtree.IndexSerde from
Expand All @@ -53,7 +53,7 @@ public class STRtreeSerializer
extends Serializer<STRtree>
{
@Override
public STRtree read(Kryo kryo, Input input, Class<STRtree> type) {
public STRtree read(Kryo kryo, Input input, Class<? extends STRtree> type) {
int nodeCapacity = input.readInt();
boolean notEmpty = (input.readByte() & 0x01) == 1;
if (notEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import org.apache.jena.sparql.graph.GraphFactory;
import org.apache.jena.util.iterator.ExtendedIterator;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/** Only used for testing Node_Graph serialization. */
public class SimpleGraphSerializer
Expand All @@ -43,7 +43,7 @@ public void write(Kryo kryo, Output output, Graph graph) {
}

@Override
public Graph read(Kryo kryo, Input input, Class<Graph> type) {
public Graph read(Kryo kryo, Input input, Class<? extends Graph> type) {
Graph result = GraphFactory.createDefaultGraph();
for (;;) {
Triple t = kryo.readObjectOrNull(input, Triple.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
import org.junit.Assert;
import org.junit.Test;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

public class TestNodeSerializer {

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<ver.org.openjdk.jmh>1.37</ver.org.openjdk.jmh>

<!-- GeoSPARQL related -->
<ver.kryo>4.0.3</ver.kryo>
<ver.kryo>5.6.2</ver.kryo>
<ver.jaxb-api>2.3.1</ver.jaxb-api>
<ver.jakarta-xml-bind>4.0.4</ver.jakarta-xml-bind>
<ver.jcommander>1.82</ver.jcommander>
Expand Down Expand Up @@ -749,8 +749,8 @@
<!-- jena-geosparql, jena-fuseki-geosparql related -->

<dependency>
<groupId>com.esotericsoftware</groupId>
<artifactId>kryo-shaded</artifactId>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo5</artifactId>
<version>${ver.kryo}</version>
</dependency>

Expand Down