Aklakan commented on PR #3027:
URL: https://github.com/apache/jena/pull/3027#issuecomment-2685952410
I am a bit worried that a hard dependency on sedona-spark may cause too many
issues, so I am trying to decouple the geometry serde (serializer/deserializer)
from the rest of the spatial-index serde.
For this, I added a plain text JSON header field to the spatial index format
with a field for the geometry serde. This field can be read and used to
configure the remaining kryo serde. The index reader makes a lookup with
Class.forName() and tries to create an instance via the default constructor.
With this approach it would be possible to use the slower JTS-based geometry
serialization for now and have a compatible upgrade path to a faster approach
at a later point.
This snippet is how the header is set up:
```java
// SpatialIndexIoKryo.java
public static void writeToOutputStream(OutputStream os,
SpatialIndexPerGraph index) {
// geometrySerde could later be switched to sedona's ShapeSerde.
// (Need to check whether I can readily reuse an interface from
JTS/Sedona instead of my own GeometrySerdeAdapter)
GeometrySerdeAdapter geometrySerde = new
GeometrySerdeAdapterJtsWkb();
JsonObject header = new JsonObject();
header.addProperty("type", "jena-spatial-index");
header.addProperty("version", "2.0.0");
header.addProperty("geometrySerde",
geometrySerde.getClass().getName());
Kryo kryo = new Kryo();
JtsKryoRegistrator.registerClasses(kryo, geometrySerde);
try (Output output = new Output(os)) {
writeJson(output, header);
writeIndex(kryo, output, index);
output.flush();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]