Open FlorianHockmann opened 5 years ago
Some related issue with array and bytecode
Sample of code
Graph graph = TinkerGraph.open();
GraphTraversalSource traversal = graph.traversal().withRemote(new EmbeddedRemoteConnection(graph.traversal()));
traversal.addV("A").property("p", new String[] { "A" }).iterate();
traversal.addV("A").property("p", new String[] { "A", "B", "C" }).iterate();
System.out.println(traversal.V().valueMap(true).toList());
Result
[{p=[A], id=0, label=A}, {p=[A], id=2, label=A}]
Actual bytecode
[[], [addV(A), property(p, A)]]
[[], [addV(A), property(p, A, B, C)]]
But expected
[[], [addV(A), property(p, [A])]]
[[], [addV(A), property(p, [A, B, C])]]
I think this is a general problem in how TinkerPop handles arrays as arguments in Bytecode. It flattens arguments contained in an array which leads to the problem you're describing.
If you create a List
instead of an array, then it should work.
Can you create an issue with TinkerPop for that? Otherwise, I can also create one.
Is this still something being considered ? It seems the TinkerPop issue is closed: https://issues.apache.org/jira/browse/TINKERPOP-2186
The TinkerPop issue was for the problem @mad described where he couldn't get the driver to actually use an array as an argument and not the elements of the array as individual arguments and Stephen provided a workaround for that in the TinkerPop issue.
That still leaves us with the question of how we can deserialize arrays in JanusGraph. We might need to add a new GraphSON type for arrays, similar to the existing TinkerPop type for List
or we just make sure that lists are deserialized as arrays for JanusGraph (or maybe both).
JanusGraph supports arrays of primitive types for property types:
Unfortunately, this feature cannot be used with GraphSON right now as we don't have serialization support for arrays. Instead, the array is serialized as a list by the driver which leads to an error on the server side:
(More information with a concrete example on gremlin-users.)