我已阅读有关匿名遍历的文档。 我明白它们可以以__
开头,并且可以在步骤调节器内使用。尽管我在概念上不理解。 为什么我们不能在步骤调节器内使用从图遍历源生成的普通遍历?例如,在以下Gremlin代码中创建边:
this.g
.V(fromId) // get vertex of id given for the source
.as("fromVertex") // label as fromVertex to be accessed later
.V(toId) // get vertex of id given for destination
.coalesce( // evaluates the provided traversals in order and returns the first traversal that emits at least one element
inE(label) // check incoming edge of label given
.where( // conditional check to check if edge exists
outV() // get destination vertex of the edge to check
.as("fromVertex")), // against staged vertex
addE(label) // add edge if not present
.property(T.id, id) // with given id
.from("fromVertex")) // from source vertexx
.next(); // end traversal to commit to graph
为什么
__.inE()
和__.addE()
是匿名的?为什么不能写成this.g.inE()
和this.g.addE()
呢?两种方式都不会引起编译器报错,那么使用匿名遍历在这里提供了什么特殊的优势呢?