JanusGraph 0.6.0 traversal change?


criminosis@...
 

When running with 0.5.2 I was able to do this traversal to add an edge between to vertices

gremlin> g.addV()
==>v[8200]
gremlin> g.addV()
==>v[4336]
gremlin> g.V(8200).addE('my_edge_label').to(g.V(4336))

But when doing it through 0.6.0 I get this now:

gremlin> g.V(8200).addE('my_edge_label').to(g.V(4336))
The child traversal of [GraphStep(vertex,[4336])] was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.IllegalStateException: The child traversal of [GraphStep(vertex,[4336])] was not spawned anonymously - use the __ class rather than a TraversalSource to construct the child traversal
at org.apache.tinkerpop.gremlin.process.traversal.Bytecode.convertArgument(Bytecode.java:302)
at org.apache.tinkerpop.gremlin.process.traversal.Bytecode.flattenArguments(Bytecode.java:287)
at org.apache.tinkerpop.gremlin.process.traversal.Bytecode.addStep(Bytecode.java:94)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.to(GraphTraversal.java:1145)
at org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal$to$4.call(Unknown Source)
at Script148.run(Script148.groovy:1)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:676)
at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:378)
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:272)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
gremlin>

After fiddling with it though I noticed I was able to do this:

gremlin> g.V(4336).as('test').V(8200).addE('my_edge_label').to('test')
==>e[2dd-6bs-xzp-3cg][8200-my_edge_label->4336]

However just doing the vertex id is not permitted, which makes sense given it's just an integer with no context.

gremlin> g.V(8200).addE('my_edge_label').to(4336)
No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.to() is applicable for argument types: (Integer) values: [4336]
Possible solutions: is(java.lang.Object), take(int), tap(groovy.lang.Closure), by(groovy.lang.Closure), drop(int), any()
I've been looking through the 0.6.0 milestone and found this issue, but that seemed more about a documentation change in 0.6.0 than a code change. Environment wise I'm just running these in a gremlin session within a docker-compose environment with Cassandra and Elasticsearch as backends.

Just wondering if the change here is intentional? Seemed weird that it was suggesting to the use "__" class too.


criminosis@...
 

Ahh I see, I guess this is the intended usage now?

gremlin> g.addV()
==>v[16496]
gremlin> g.addV()
==>v[4096]
gremlin> g.V(16496).addE('user_alias').to(__.V(4096))
==>e[4cu-cq8-xzp-35s][16496-user_alias->4096]
gremlin>
Basically doing "__.V" instead of "g.V" for the child traversal?


Clement de Groc
 

Yes. In JanusGraph 0.6.0, Apache TinkerPop was upgraded to 3.5.1 and requires using an anonymous traversal in such cases.
This is mentioned in their "Upgrade for users" guide here: https://tinkerpop.apache.org/docs/current/upgrade/#_anonymous_child_traversals


Florian Hockmann
 

Yes, exactly. This was a breaking change in TinkerPop 3.5.0 which is included in JanusGraph 0.6.0: https://tinkerpop.apache.org/docs/current/upgrade/#_anonymous_child_traversals

 

 

Von: janusgraph-users@... <janusgraph-users@...> Im Auftrag von criminosis@...
Gesendet: Dienstag, 25. Januar 2022 00:09
An: janusgraph-users@...
Betreff: Re: [janusgraph-users] JanusGraph 0.6.0 traversal change?

 

Ahh I see, I guess this is the intended usage now?

gremlin> g.addV()

==>v[16496]

gremlin> g.addV()

==>v[4096]

gremlin> g.V(16496).addE('user_alias').to(__.V(4096))
==>e[4cu-cq8-xzp-35s][16496-user_alias->4096]
gremlin>

Basically doing "__.V" instead of "g.V" for the child traversal?


criminosis@...
 

Duly noted. I'll keep in mind to dig deeper when seeing closed issues mentioning Tinkerpop updates. Thanks everyone!