You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "stephen mallette (JIRA)" <ji...@apache.org> on 2019/04/17 15:52:02 UTC
[jira] [Closed] (TINKERPOP-2186) Wrong translation to bytecode from
array value
[ https://issues.apache.org/jira/browse/TINKERPOP-2186?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
stephen mallette closed TINKERPOP-2186.
---------------------------------------
Resolution: Not A Problem
I say "not a problem" but it's more like I have a workaround - you have to wrap the array you want in an array and it works:
{code}
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal().withRemote(new EmbeddedRemoteConnection(graph.traversal()))
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> g.addV("A").property("p", [[ "A" ] as String[]] as Object[]).iterate()
gremlin> g.addV("A").property("p", [[ "A", "B", "C" ] as String[]] as Object[]).iterate()
gremlin> g.V().valueMap(true).toList()
==>[p:[[A]],id:0,label:A]
==>[p:[[A, B, C]],id:2,label:A]
gremlin> g.V().values("p").map{it.get().getClass()}
==>class [Ljava.lang.String;
==>class [Ljava.lang.String;
{code}
The trick is that bytecode has to deal with those varargs steps and it doesn't know whether your string array is to be called as varargs or explicitly as a single array object. I don't know how we can resolve that programmatically, so i think we have to rely on the explicit definition by way of the wrapping in the {{Object[]}}
> Wrong translation to bytecode from array value
> ----------------------------------------------
>
> Key: TINKERPOP-2186
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2186
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.4.1
> Reporter: Pavel
> Assignee: stephen mallette
> Priority: Major
>
> Sample of code
> {code:java}
> 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());
> {code}
> Result
> {code:java}
> [{p=[A], id=0, label=A}, {p=[A], id=2, label=A}]
> {code}
> Actual bytecode
> {code}
> [[], [addV(A), property(p, A)]]
> [[], [addV(A), property(p, A, B, C)]]
> {code}
> But expected
> {code}
> [[], [addV(A), property(p, [A])]]
> [[], [addV(A), property(p, [A, B, C])]]
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)