Gremlin.Net System.InvalidOperationException: '

2019-07-26 06:59发布

问题:

I am new in janusgraph and tinkerpop. I am using Gremlin.Net 3.2.7 to connect to janusgraph and all the request that return vertexes work fine for me but when I run any operation that return edges like "g.V(61464).outE('father').toList()" an exception in the library:

System.InvalidOperationException: 'Deserializer for "janusgraph:RelationIdentifier" not found'

the server didn't throw any exception, the serializes configuration are the default:

serializers:

 - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
 - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0, config: {ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
 - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
 - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}
 - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
 - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistryV1d0] }}

but its working fine in the gremlin-client console. do you have any suggestion plz?

回答1:

It looks like JanusGraph serializes edges in its own format as RelationIdentifiers which aren't part of TinkerPop. So Gremlin.Net has no deserializer for this type. This means that you either have to implement your own GraphSON deserializer for this type or you change your Gremlin query to not return edges directly.

The TinkerPop docs contain an example on how to write a deserializer for Gremlin.Net. (Note that you only have to implement an IGraphSONDeserializer, not IGraphSONSerializer as that's only used for writing.)

Or, if you instead want to change your Gremlin traversal, than you can for example just return the edge properties:

g.V(61464).OutE("father").ValueMap<object>().ToList();

BTW: It looks like you are sending your Gremlin traversals in the form of Gremlin-Groovy strings to the JanusGraph server. You can instead also write Gremlin traversals directly in C# with Gremlin.Net. This makes it not only easier to write the traversal, but the execution is also more efficient on the server-side.