You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by dkuppitz <gi...@git.apache.org> on 2018/07/12 17:25:39 UTC

[GitHub] tinkerpop pull request #876: TINKERPOP-967 Support nested-repeat() structure...

Github user dkuppitz commented on a diff in the pull request:

    https://github.com/apache/tinkerpop/pull/876#discussion_r202102880
  
    --- Diff: docs/src/reference/the-traversal.asciidoc ---
    @@ -2125,6 +2125,17 @@ traverser repeats. However, because the emit-predicate is declared true, those v
       Given that `loops==2`, the until-predicate fails and ripple and lop are emitted.
     Therefore, the traverser has seen the vertices: lop, vadas, josh, ripple, and lop.
     
    +`repeat()`-steps may be nested inside each other or inside the `emit()` or `until()` predicates and they can also be 'named' by passing a string as the first parameter to `repeat()`. The loop counter of a named repeat step can be accessed within the looped context with `loops(loopName)` where `loopName` is the name set whe creating the `repeat()`-step.
    +
    +[gremlin-groovy,modern]
    +----
    +g.V(1).repeat(out("knows")).until(__.repeat(out("created")).emit(__.has("name", "lop"))) <1>
    +g.V(6).repeat('a', both('created')).emit(repeat('b', __.both('knows')).until(or(loops().is(2), loops('b').is(loops('a')))).hasId(2)).dedup() <2>
    --- End diff --
    
    I haven't tried it yet, but I don't think this query does what the description says. It only works because it has the early break condition `loops().is(2)`. `.is(loops('a'))`, on the other hand, should always return `false`, since it's comparing the incoming `Long` value against a `Traversal`. To match the description, the query should look more like this (IMO):
    
    ```
    g.V(6).
      repeat('a', both('created').simplePath()).
        emit(repeat('b', __.both('knows')).
               until(loops('b').as('b').where(loops('a').as('b')))).
      hasId(2)).dedup()
    ```


---