tinkerpop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marko A. Rodriguez (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TINKERPOP3-760) Make loop counter accessible within repeat()
Date Sat, 01 Aug 2015 14:37:04 GMT

    [ https://issues.apache.org/jira/browse/TINKERPOP3-760?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14650366#comment-14650366

Marko A. Rodriguez commented on TINKERPOP3-760:

Cool. We should have a chat about "nested loop" as once we figure out how that will look,
then we can do {{LoopsStep}}. I did some thinking last night and I suspect that {{...loops()...}}
will behave and be as you had it, we just need to make sure so we don't get into a backwards
compatible issue come "nested loops." Here is the problem.

for(int i...) {
  for(int j...) {
      // I have access to both i and j

{{TraverserRequirement.NESTED_LOOPS}} will be like above. With {{loops()}} that would only
give us {{j}}. How do I get {{i}}? I have no good idea. As I see it, I think that {{Traverser}}
will have to implement some sort of "loop stack" where when one {{repeat()}} is exited, the
loop stack is pop'd. The problem here is that we don't have variable names for {{repeat}}
sections -- i.e. no way of saying {{i}} vs. {{j}}. The simplest thing would be like {{...loops(1)...}}
which means, the loop count 1 stack element deep. ???. .. :|

> Make loop counter accessible within repeat()
> --------------------------------------------
>                 Key: TINKERPOP3-760
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-760
>             Project: TinkerPop 3
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.0.0-incubating
>            Reporter: Daniel Kuppitz
>            Assignee: Daniel Kuppitz
>             Fix For: 3.1.0-incubating
> Currently we can access the loop counter in a lambda:
> {code}
> .filter {it.loops() < 3}
> {code}
> Would be nice to have a step to access the counter:
> {code}
> .where(loops().is(lt(3)))
> {code}

This message was sent by Atlassian JIRA

View raw message