[ 
https://issues.apache.org/jira/browse/TINKERPOP-967?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16541981#comment-16541981
 ] 

ASF GitHub Bot commented on TINKERPOP-967:
------------------------------------------

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()
    ```


> Support nested-repeat() structures
> ----------------------------------
>
>                 Key: TINKERPOP-967
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-967
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.1.0-incubating
>            Reporter: Marko A. Rodriguez
>            Assignee: Marko A. Rodriguez
>            Priority: Major
>
> All the internal plumbing is staged for this to happen, we just haven't gone 
> all the way. In short, a {{NESTED_LOOP}} traverser has an internal 
> {{loopStack}} where {{repeat(repeat())}} will have a {{loopStack}} of two. 
> The {{it.loops()}} checks of the internal repeat will always check the top of 
> the stack and when its done repeating will delete its counter off the top of 
> the stack.
> [~dkuppitz]'s work on {{LoopStep}} will be backwards compatible. In 
> {{RepeatStep}} we will support:
> {code}
> repeat('a',out('knows').repeat('b',out('parent')))
> {code}
> and thus, things like {{loops('a')}} as well as {{times('a',2)}}. Note that 
> naming the loop stack will be a super rare case as most people will just 
> assume standard nested looping semantics with a push/pop stack.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to