Re: Geoshape property in remote gremlin query, GraphSON


Robert Dale <rob...@...>
 

Using cluster/client will work with the v1 serializer.

gremlin-server.yaml:

serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}


conf/remote.yaml:
hosts: [localhost]
port
: 8182
serializer
: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] } }


connect:
gremlin> cluster = Cluster.open('conf/remote.yaml')
==>localhost/127.0.0.1:8182
gremlin
> client = cluster.connect();
==>org.apache.tinkerpop.gremlin.driver.Client$ClusteredClient@434514d8
gremlin> client.submit("g.addV().property('geo', Geoshape.point(0.0,1.1))")
==>result{object={id=4152, label=vertex, type=vertex, properties={geo=[{id=sn-37c-sl, value=POINT (1.1 0)}]}} class=java.util.HashMap}
gremlin> client.submit("g.V().values('geo')").all().get().get(0).getObject()
==>POINT (1.1 0)
gremlin> client.submit("g.V().values('geo')").all().get().get(0).getObject().getClass()
==>class org.janusgraph.core.attribute.Geoshape



You won't be able to use withRemote() with the V1 serializer.



On Wednesday, July 19, 2017 at 3:16:37 PM UTC-4, Robert Dale wrote:
It seems Geoshape GraphSON support is hardcoded to v1 although I couldn't get it to work with that either.  If you have to use GraphSON instead of Gryo, then you could checkout master, apply this patch, and rebuild. I created an  issue to support multiple versions of serializers  https://github.com/JanusGraph/janusgraph/issues/420

diff --git a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java
index
6ef907b..8168309 100644
--- a/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java
+++ b/janusgraph-core/src/main/java/org/janusgraph/graphdb/tinkerpop/io/graphson/JanusGraphSONModule.java
@@ -50,10 +50,10 @@ public class JanusGraphSONModule extends TinkerPopJacksonModule {
     
private JanusGraphSONModule() {
         
super("janusgraph");
         addSerializer
(RelationIdentifier.class, new RelationIdentifierSerializer());
-        addSerializer(Geoshape.class, new Geoshape.GeoshapeGsonSerializerV1d0());
+        addSerializer(Geoshape.class, new Geoshape.GeoshapeGsonSerializerV2d0());
 
         addDeserializer
(RelationIdentifier.class, new RelationIdentifierDeserializer());
-        addDeserializer(Geoshape.class, new Geoshape.GeoshapeGsonDeserializerV1d0());
+        addDeserializer(Geoshape.class, new Geoshape.GeoshapeGsonDeserializerV2d0());
     
}
 
     
private static final JanusGraphSONModule INSTANCE = new JanusGraphSONModule();



On Tuesday, July 18, 2017 at 5:47:50 PM UTC-4, Conrad Rosenbrock wrote:
I am trying to assign a value to a property with the native Geoshape type. I have it serialized into JSON as follows (where g is aliased to the traversal on gremlin server):

{"@value": {"type": "point", "coordinates": [{"@value": 1.1, "@type": "g:Double"}, {"@value": 2.2, "@type": "g:Double"}]}, "@type": "g:Geoshape"}

In the gremlin console, I can easily type 

Geoshape.point(1.1, 2.2)

and it works perfectly. I am sure that it is something quite simple. Here is the error:

Request [PooledUnsafeDirectByteBuf(ridx: 653, widx: 653, cap: 687)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV2d0.

For reference, I do have the following serializer in the gremlin server config:

{ className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}

which should direct gremlin server to the relevant deserializer in Janus.

Thanks!

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.