> With a first query I want to calculate the impact of changing a source
> file (the transitive closure). A similar question was already
> discussed on this list [0]. The difference is, that I need to loop
> until I collected all reachable vertices and not only while (it.loops
> < X).
>
> This is my current query:
>
> //results is a Set which I put into scope via jsr223
> visited = [] as Set
> g.idx('I')
> [['name':'A']].as('X').aggregate(results).back(1).outE('link').except(visited).aggregate(visited).back(1).inV.loop('X')
> {true}
> 1. Is this correct? Are there more elegant ways to do this?
Looping and aggregate are not going to behave well together. More on that later.
> 2. In my first approach I tracked whether the visited set has changed
> to phrase a loop termination condition. But the loop terminates in the
> above query because the loop step is not reachable anymore (guarded by
> except(visited)). Is this reasoning correct?
Its dies cause of aggregrate() locking. More on that later.
> 3. Although 'aggregate' is described as 'emits input, but adds input
> to a collection' I need the back(1) to get the expected behaviour.
> Does this relate to https://github.com/tinkerpop/gremlin/issues/207 ?
Yea. I need to rectify this issue. I believe I know how to do it, but haven't gotten around to it. In short, aggregate() will "while(next)" to fill the provided collection (e.g. results). Once its drained the while(next), it will lock and only provide an iterator to the provided collection. As such, when looping, the aggregate() step is locked from the previous loop and thus, this causes problems. ... .or, behavior that is not generally desired.
SIDENOTE: In your example query, you don't need to go back(1) as aggregate just streams the collection provided.
Let me work on that ticket as it has been a problem for others. Keep an eye to the list to see how it develops.
> Again many thanks for this great project! Expect some more questions
> in the near future.
No problem. Keep them coming.
Thanks Daniel,
Marko.
> many thanks for your explanations. After having a look at the
> implementation of AggregatorPipe [0] I think I can see now what
> happens. 'aggregate' is much more powerful and different from what I
> expected after reading its step description [1] on the github wiki.
Yea. AggregatorPipe is very much a different kind of pipe than the rest. It truly is what makes the Gremlin's depth-first architecture into a breadth-first one.
> You may want to adjust the description from:
> 'emits input, but adds input to a collection'
> to something along the line:
> 'adds input to collection, emits collection'
I'm actually working on a rewrite of AggregatorPipe right now. In short, it will always emit what came through it and, in the background, fill the aggregation collection.
Given the nature of this situation --- you've touched a very critical aspect of Gremlin --- perhaps we can IM and go back and forth on things as I'm doing some work that may be of use to you and would like to iterate on it with you.
My Jabber/XMPP is okram...@gmail.com or skyparko on Skype.
Thanks,
Marko.