Hi all,

The current gremlin-semantics documentation for the repeat() step doesn't
specify how traversal state should be handled between iterations. The
wording does suggest that the same traversal should be applied iteratively,
and this is what the reference implementation's behavior is. This leads to
some interesting behavior for steps that keep global state. An example of
this was the limit() step. This step kept track of how many traversers had
been seen and filters out anything above a high value. When used inside
repeat, the state of this step never reset so it meant that for most
traversals, it would filter out all the traversers. This behavior was
discussed and changed to be per-iteration scoped in [1]. This type of
behavior aligns more closely to what RepeatUnrollStrategy does, and I'd
argue that it's what most new users would expect the behavior to be. The
difference here is that, after each iteration, the traversal will be reset
rather than keeping its state. Alternatively, and equally, a freshly cloned
traversal could be used per iteration. The only exception to this rule is
dedup() which is also excluded by the RepeatUnrollStrategy.

If there are no concerns around this, then starting in 3.8.0, I think the
semantics should be changed so that a "fresh" traversal is used per
iteration, with the exception of dedup() which remains global and isn't
reset.

Thanks,
Ken

[1]: https://lists.apache.org/thread/nclqpdb5d9wm6cgdxkk39k0co7gt564l

Reply via email to