Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of double underscore in repeat() or other steps in Tinkerpop Gremlin?

I have noticed double underscore being used in some step functions in Tinkerpop Gremlin 3.3. Could someone please tell why we use this double underscore with an example ? I could not find enough information about this in the documentation.

like image 927
livetolearn Avatar asked Dec 18 '22 02:12

livetolearn


1 Answers

__. allows you to define an anonymous Traversal, ie. a Traversal which is not bound to a specific TraversalSource.

In the Gremlin console, all Gremlin steps are statically imported so you never need to prefix anonymous traversals with __. unless that anonymous traversal starts with a reserved keyword in the target language. In Groovy, which is the default Gremlin flavor, this is the case with in() and as() steps: because these are reserved keywords, these two steps must be prefixed with __.

In Java, you can avoid __. prefix by statically importing all steps in your program:

import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__

See the small Note section in the documentation: http://tinkerpop.apache.org/docs/3.3.0/reference/#graph-traversal-steps

like image 178
jbmusso Avatar answered May 12 '23 19:05

jbmusso