You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "andreachild (via GitHub)" <gi...@apache.org> on 2025/10/16 01:08:14 UTC
[PR] Change range() in repeat() to track counters per iteration [tinkerpop]
andreachild opened a new pull request, #3241:
URL: https://github.com/apache/tinkerpop/pull/3241
https://issues.apache.org/jira/browse/TINKERPOP-3202
This changeset aligns the semantics of traversals with `range()` and `limit()` used in `repeat()` with the behaviour of the equivalent 'unrolled' traversal without `repeat()`. This is done by tracking per-iteration counters instead of a global counter. The semantics of `range()` and `limit()` without `repeat()` and with `local()` were not modified.
Single and nested loop `Traverser` implementations were also refactored to reduce much code duplication by consolidating common loop logic into a new `NL_SL_Traverser` base interface for loop-aware traversers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441457585
##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java:
##########
@@ -131,7 +131,7 @@ public void shouldApplyStrategiesCorrectly() {
}
assertEquals(4, found);
//
- //System.out.println(traversal.explain().prettyPrint(160));
+ System.out.println(traversal.explain().prettyPrint(170));
Review Comment:
It was intentional to help troubleshoot a flaky test that was sometimes failing in github actions but not locally, but I have reverted it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445966936
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
+==>[name:[vp[name->BLACK THROATED WIND]]]
+gremlin> g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+==>DEAL
+==>WOMEN ARE SMARTER
+// 3.8.0 - modern graph examples demonstrating consistent skip semantics
+gremlin> g.V(1).repeat(out().skip(1)).times(2).values('name')
+==>lop
+gremlin> g.V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+----
+
+This change ensures that globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` now use per-iteration
+counters, making the behavior consistent with manually unrolled traversals. Locally-scoped variants of these steps are
Review Comment:
"Locally-scoped" has a similar issue to "globally-scoped" mentioned earlier: https://github.com/apache/tinkerpop/pull/3241/files#r2445965186 - just needs a different phrasing/introduction or something
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446776072
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
+==>[name:[vp[name->BLACK THROATED WIND]]]
+gremlin> g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+==>DEAL
+==>WOMEN ARE SMARTER
+// 3.8.0 - modern graph examples demonstrating consistent skip semantics
+gremlin> g.V(1).repeat(out().skip(1)).times(2).values('name')
+==>lop
+gremlin> g.V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+----
+
+This change ensures that globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` now use per-iteration
+counters, making the behavior consistent with manually unrolled traversals. Locally-scoped variants of these steps are
+not affected by these changes.
Review Comment:
Added note to look for existing traversals with these steps inside repeat and move the steps outside of the loop if they want the limits to be applied across all loops
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#issuecomment-3423605115
VOTE +1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2436788633
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
Review Comment:
It might be good to add a query that uses limit more than once in the repeat traversal. Something like:
`g.withoutStrategies(RepeatUnrollStrategy,EarlyLimitStrategy).V(5).repeat(limit(1).in().limit(1).limit(1)).times(2).values("name")`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445783074
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,38 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() and range() Semantics in repeat()
Review Comment:
I've added details to the semantics doc under the `repeat` step regarding the use of `range` steps inside `repeat`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446811368
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
I'm not sure if performance comparison of range in repeat for 3.7 vs 3.8 is useful due to the semantics change - it is expected that 3.8 would be 'slower' because traversers that were previously filtered in 3.7 would now be passed to subsequent iterations and steps for processing.
I would like to get this PR merged before our 3.8 gameday tomorrow but I can follow up with some `GraphTraversalBenchmark` tests comparing `range()` without `repeat()` in 3.7 vs 3.8. This would analyze the impact of replacing a single `AtomicLong` counter with a singleton `Map` of one counter entry.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#issuecomment-3427387308
VOTE +1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446772441
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,25 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit(), skip(), range() inside repeat()
+
+When using globally-scoped (default scope) `limit()`, `skip()`, or `range()` steps inside `repeat()`, each iteration of
Review Comment:
Removed the specific header and moved the examples to enhance the existing examples. Also fixed the modulator description to include `times()` modulator along with existing descriptions for `emit()` and `until()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438409471
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
Review Comment:
thanks, added that suggestion and another for the unrolled version of that traversal
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445950337
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
Review Comment:
interesting that `in` works anonymously. please change it to `__.in` though because it could be just a trick of Groovy/JVM that it's working now. i'm not sure we ever did anything to actually ensure it calls that properly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441109844
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
+ return false;
+ }
throw FastNoSuchElementException.instance();
}
long avail = traverser.bulk();
- if (this.counter.get() + avail <= this.low) {
+ if (counter.get() + avail <= this.low) {
// Will not surpass the low w/ this traverser. Skip and filter the whole thing.
- this.counter.getAndAdd(avail);
+ counter.getAndAdd(avail);
return false;
}
// Skip for the low and trim for the high. Both can happen at once.
long toSkip = 0;
- if (this.counter.get() < this.low) {
- toSkip = this.low - this.counter.get();
+ if (counter.get() < this.low) {
+ toSkip = this.low - counter.get();
}
long toTrim = 0;
- if (this.high != -1 && this.counter.get() + avail >= this.high) {
- toTrim = this.counter.get() + avail - this.high;
+ if (this.high != -1 && counter.get() + avail >= this.high) {
+ toTrim = counter.get() + avail - this.high;
}
long toEmit = avail - toSkip - toTrim;
- this.counter.getAndAdd(toSkip + toEmit);
+ counter.getAndAdd(toSkip + toEmit);
traverser.setBulk(toEmit);
return true;
}
+ private String getCounterKey(Traverser.Admin<S> traverser) {
+ List<String> counterKeyParts = new ArrayList<>();
+ Traversal.Admin<Object, Object> traversal = this.getTraversal();
+ if (traversal.getParent() instanceof RepeatStep) {
Review Comment:
I've changed all checks for repeat parent to check all parents until the root
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2453441518
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
Follow up PR to improve performance: https://github.com/apache/tinkerpop/pull/3251
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2436742647
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,181 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).times(2).values("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_untilXloopsXisX2XXX_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).until(loops().is(2)).values("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_limitX1X_in_limitX1X_in_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).limit(1).in().limit(1).in().values("name")
Review Comment:
Nit: Usage of `withoutStrategies(RepeatUnrollStrategy)` even though there is no `repeat()`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445893746
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,25 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit(), skip(), range() inside repeat()
+
+When using globally-scoped (default scope) `limit()`, `skip()`, or `range()` steps inside `repeat()`, each iteration of
+the repeat gets its own counter, ensuring consistent behavior across iterations:
+
+[gremlin-groovy,grateful-dead]
+----
+g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(3) <1>
+g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2) <2>
Review Comment:
i think that's going to have to be `__.in` or groovy won't process it when the documentation is generated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445911904
##########
docs/src/dev/provider/gremlin-semantics.asciidoc:
##########
@@ -2034,6 +2034,14 @@ message containing: `The repeat()-traversal was not defined`.
- Nested repeats and loop names:
- Nested `repeat()` steps maintain separate loop counters. Use `repeat("a", ...)` and `loops("a")` to reference a
specific counter inside nested loops.
+- Range steps (`limit()`, `skip()`, `range()`) in `repeat()`:
Review Comment:
The additions here speak of `repeat` generally, but sort of all focus on usage with `times`. Without the context of this overall issue, I think it might be confusing to readers who don't have the context. Know what I mean?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446016763
##########
CHANGELOG.asciidoc:
##########
@@ -113,6 +113,7 @@ This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
* Renamed `MergeElementStep` to `MergeElementStep` as it is a base class to `mergeV()` and `mergeE()`.
* Renamed `MergeStep` of `merge()` to `MergeElementStep` for consistency.
* Modified `RepeatUnrollStrategy` to use a more conservative approach, only unrolling repeat loops containing safe navigation and filtering steps.
+* Modified `limit()` and `range()` in `repeat()` to track per-iteration counters.
Review Comment:
i think this is a case where you might add at least one extra entry:
```
* Introduced `NL_SL_Traverser` for `Traverser` types supporting loops.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy merged PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438306811
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
Could there potentially be performance impacts with deeply nested and complex repeat queries? I don't have any example to offer, but just wondering for awareness.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445906983
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,25 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit(), skip(), range() inside repeat()
+
+When using globally-scoped (default scope) `limit()`, `skip()`, or `range()` steps inside `repeat()`, each iteration of
Review Comment:
I don't think there's enough context here introducing this concept, but I'm also not sure it needs to be introduced. As this is the Reference Documentation, does it need this special description of these steps inside of `repeat`? In other words, if you just came to this section as a new user, you wouldn't have any frame of reference for how else these steps were to interact with each other. You'd only have how they work together today. I feel like it would be far more useful to have the behavior of `times` described to me clearly, with patterns or use cases that helped explain what the behavior is.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446774521
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
Review Comment:
That was a mistake, I have fixed the output to only have the names
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446780899
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,239 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
Review Comment:
There's actually a nested traversal for range:
```
Scenario: g_VX5X_repeatXrangeX0_1X_in_repeatXrangeX0_1X_inX_timesX1XX_timesX1X_valuesXnameX
Given the modern graph
And using the parameter vid5 defined as "v[ripple].id"
And the traversal of
"""
g.V(vid5).repeat(range(0, 1).in().repeat(range(0, 1).in()).times(1)).times(1).values("name")
"""
When iterated to list
Then the result should be unordered
| result |
| marko |
```
I've also added nested tests to `TinkerGraphRepeatRangeGlobalTest.java`.
Each `range` step in this example has its own set of iteration counters in isolation from the other.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441455833
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
Review Comment:
> I think it's b/c even though NL traversers contain SL, implementation wise they extend but overrode the SL logic, so essentially it is one or the other?
This is exactly why. The NL traversers all extend SL traversers but override all `loops` related methods to reference the nested loop stack and the single loop counter is essentially unused.
Yes all NL traversers do support SL but do so using the NL stack data structure, ignoring the SL loop counter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441132904
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
Review Comment:
Added this suggestion including others using limit in union in repeat
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446776453
##########
CHANGELOG.asciidoc:
##########
@@ -113,6 +113,7 @@ This release also includes changes from <<release-3-7-XXX, 3.7.XXX>>.
* Renamed `MergeElementStep` to `MergeElementStep` as it is a base class to `mergeV()` and `mergeE()`.
* Renamed `MergeStep` of `merge()` to `MergeElementStep` for consistency.
* Modified `RepeatUnrollStrategy` to use a more conservative approach, only unrolling repeat loops containing safe navigation and filtering steps.
+* Modified `limit()` and `range()` in `repeat()` to track per-iteration counters.
Review Comment:
Added extra entry for the refactoring done for loop traversals
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446775157
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
+==>[name:[vp[name->BLACK THROATED WIND]]]
+gremlin> g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+==>DEAL
+==>WOMEN ARE SMARTER
+// 3.8.0 - modern graph examples demonstrating consistent skip semantics
+gremlin> g.V(1).repeat(out().skip(1)).times(2).values('name')
+==>lop
+gremlin> g.V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+----
+
+This change ensures that globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` now use per-iteration
+counters, making the behavior consistent with manually unrolled traversals. Locally-scoped variants of these steps are
Review Comment:
Fixed by referencing `Scope.global` specifically
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446768209
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
Review Comment:
Added explanation why the strategy is disabled for 3.7.4 but not 3.8.0 examples
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441458208
##########
tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphRepeatRangeGlobalTest.java:
##########
@@ -0,0 +1,759 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.tinkergraph.structure;
+
+import java.util.List;
+import java.util.function.Function;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class TinkerGraphRepeatRangeGlobalTest {
+ private static GraphTraversalSource gSource;
+ private static GraphTraversalSource gComputerSource;
+
+ @BeforeClass
+ public static void setup() {
+ gSource = TinkerGraph.open().traversal().withoutStrategies(RepeatUnrollStrategy.class);
+ load(gSource);
+ gComputerSource = gSource.withComputer(Computer.compute().workers(3));
+ }
+
+ @Test
+ public void testBasicRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows")
+ .limit(1).out("knows"));
+ }
+
+ @Test
+ public void testBasicRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(2).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(2).out("knows")
+ .limit(2).out("knows"));
+
+ }
+
+ @Test
+ public void testRepeatOutLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ // adding order inside repeat breaks things
+ .repeat(__.out("knows").limit(2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").limit(2)
+ .out("knows").limit(2));
+ }
+
+ @Test
+ public void testRepeatWithBothAndLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.both("knows").order().by("id").limit(3))
+ .times(2),
+ s -> s.V().has("id", "l3-0")
+ .both("knows").order().by("id").limit(3)
+ .both("knows").order().by("id").limit(3));
+ }
+
+ @Test
+ public void testRepeatWithFilterAndLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").has("id", P.neq("l4-3")).order().limit(2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").has("id", P.neq("l4-3")).order().limit(2)
+ .out("knows").has("id", P.neq("l4-3")).order().limit(2));
+ }
+
+ @Test
+ public void testChainedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").limit(1).out("knows")).times(2)
+ .repeat(__.order().by("id").limit(1).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows"));
+ }
+
+ @Test
+ public void testChainedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").limit(2).out("knows")).times(2)
+ .repeat(__.order().by("id").limit(3).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").limit(1).out("knows")
+ .repeat(__.order().by("id").limit(1).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").limit(2).out("knows")
+ .repeat(__.order().by("id").limit(3).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows")
+ .repeat(__.limit(1).in("knows")
+ .repeat(__.limit(1).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(2).out("knows")
+ .repeat(__.limit(3).in("knows")
+ .repeat(__.limit(4).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(2).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(2).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows"));
+ }
+
+ @Test
+ public void testAggregateRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows").aggregate("x")
+ .limit(1).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testAggregateRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(3).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .limit(3).out("knows").aggregate("x")
+ .limit(3).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testUnionRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .repeat(__.limit(1)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .limit(1));
+ }
+
+ @Test
+ public void testUnionRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .repeat(__.limit(3)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .limit(3));
+ }
+
+ @Test
+ public void testBasicRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows"));
+ }
+
+ @Test
+ public void testBasicRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 2).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 2).out("knows")
+ .range(0, 2).out("knows"));
+ }
+
+ @Test
+ public void testRepeatOutRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").range(0, 2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").range(0, 2)
+ .out("knows").range(0, 2));
+ }
+
+ @Test
+ public void testRepeatWithBothAndRange() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.both("knows").order().by("id").range(0, 3))
+ .times(2),
+ s -> s.V().has("id", "l3-0")
+ .both("knows").order().by("id").range(0, 3)
+ .both("knows").order().by("id").range(0, 3));
+ }
+
+ @Test
+ public void testRepeatWithFilterAndRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").has("id", P.neq("l4-3")).order().range(0, 2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").has("id", P.neq("l4-3")).order().range(0, 2)
+ .out("knows").has("id", P.neq("l4-3")).order().range(0, 2));
+ }
+
+ @Test
+ public void testChainedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").range(0, 1).out("knows")).times(2)
+ .repeat(__.order().by("id").range(0, 1).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows"));
+ }
+
+ @Test
+ public void testChainedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").range(0, 2).out("knows")).times(2)
+ .repeat(__.order().by("id").range(0, 3).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").range(0, 1).out("knows")
+ .repeat(__.order().by("id").range(0, 1).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").range(0, 2).out("knows")
+ .repeat(__.order().by("id").range(0, 3).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows")
+ .repeat(__.range(0, 1).in("knows")
+ .repeat(__.range(0, 1).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 2).out("knows")
+ .repeat(__.range(0, 3).in("knows")
+ .repeat(__.range(0, 4).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 2).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 2).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows"));
+ }
+
+ @Test
+ public void testAggregateRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows").aggregate("x")
+ .range(0, 1).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testAggregateRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 3).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 3).out("knows").aggregate("x")
+ .range(0, 3).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testUnionRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .repeat(__.range(0, 1)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .range(0, 1));
+ }
+
+ @Test
+ public void testUnionRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .repeat(__.range(0, 3)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .range(0, 3));
+ }
+
+ private void testTraversals(Function<GraphTraversalSource, GraphTraversal<Vertex, Vertex>> repeatFunction,
+ Function<GraphTraversalSource, GraphTraversal<Vertex, Vertex>> nonRepeatFunction) {
+ List<?> repeatTraversal = repeatFunction.apply(gSource).toList();
+ List<?> withComputerTraversal = repeatFunction.apply(gComputerSource).toList();
+ List<?> nonRepeatTraversal = nonRepeatFunction.apply(gSource).toList();
+ assertFalse(repeatTraversal.isEmpty());
+ assertTrue(CollectionUtils.isEqualCollection(repeatTraversal, nonRepeatTraversal));
+ // due to non-sequential processing of computer algorithm, can not assert equality but only size
+ assertEquals(repeatTraversal.size(), withComputerTraversal.size());
+ }
+
+ private static void load(GraphTraversalSource g) {
Review Comment:
It is specific to this test as I wanted a very predictable structured data to traverse through. For feature tests and local testing the grateful dead graph can be used instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#issuecomment-3408835699
## [Codecov](https://app.codecov.io/gh/apache/tinkerpop/pull/3241?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:warning: Please [upload](https://docs.codecov.com/docs/codecov-uploader) report for BASE (`3.8-dev@f2bd35e`). [Learn more](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#section-missing-base-commit) about missing BASE report.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 3.8-dev #3241 +/- ##
==========================================
Coverage ? 75.68%
==========================================
Files ? 28
Lines ? 6383
Branches ? 0
==========================================
Hits ? 4831
Misses ? 1331
Partials ? 221
```
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/tinkerpop/pull/3241?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2437142607
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,38 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() and range() Semantics in repeat()
Review Comment:
Not sure if we also want to highlight this in the Provider section, but we should add an entry into the `gremlin-semantics` doc on this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438415861
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
+ * Implementations are expected to override either the single or nested loop functions depending on the type of loop
+ * they are supporting.
+ * <p>
+ * Note: it would be nice to separate the {@link TraverserRequirement#SINGLE_LOOP} vs {@link TraverserRequirement#NESTED_LOOP}
+ * logic into different traverser interfaces in the future however the current {@link Traverser} class hierarchy makes
+ * that difficult as {@link Traverser}s that support nested loops extend from {@link Traverser}s that support single
+ * loops but override all single loop logic with nested loop logic.
+ */
+public interface NL_SL_Traverser<T> extends Traverser.Admin<T> {
+ /**
+ * @return the supported loop type - either {@link TraverserRequirement#NESTED_LOOP} or {@link TraverserRequirement#SINGLE_LOOP}
+ */
+ TraverserRequirement getLoopRequirement();
+
+ // NESTED LOOPS
+
+ /**
+ * Override this method to support nested loops.
+ *
+ * @return the {@link Stack} of {@link LabelledCounter} which holds the nested loops.
+ */
+ default Stack<LabelledCounter> getNestedLoops() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Override this method to support nested loops.
+ *
+ * @return the {@link ReferenceMap} where key=loop name and value=reference to the {@link LabelledCounter}.
+ */
+ default ReferenceMap getNestedLoopNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ // SINGLE LOOPS
+
+ /**
+ * Override this method to support single loop.
+ *
+ * @return the single loop count.
+ */
+ default short getSingleLoopCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Override this method to support single loop. Sets the single loop count.
+ */
+ default void setSingleLoopCount(short loops) {
Review Comment:
added finals where possible
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
+ return false;
+ }
throw FastNoSuchElementException.instance();
}
long avail = traverser.bulk();
- if (this.counter.get() + avail <= this.low) {
+ if (counter.get() + avail <= this.low) {
// Will not surpass the low w/ this traverser. Skip and filter the whole thing.
- this.counter.getAndAdd(avail);
+ counter.getAndAdd(avail);
return false;
}
// Skip for the low and trim for the high. Both can happen at once.
long toSkip = 0;
- if (this.counter.get() < this.low) {
- toSkip = this.low - this.counter.get();
+ if (counter.get() < this.low) {
+ toSkip = this.low - counter.get();
}
long toTrim = 0;
- if (this.high != -1 && this.counter.get() + avail >= this.high) {
- toTrim = this.counter.get() + avail - this.high;
+ if (this.high != -1 && counter.get() + avail >= this.high) {
+ toTrim = counter.get() + avail - this.high;
}
long toEmit = avail - toSkip - toTrim;
- this.counter.getAndAdd(toSkip + toEmit);
+ counter.getAndAdd(toSkip + toEmit);
traverser.setBulk(toEmit);
return true;
}
+ private String getCounterKey(Traverser.Admin<S> traverser) {
Review Comment:
added finals where possible
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2437917792
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
Review Comment:
This check should probably apply recursively to grandparents etc. Otherwise nesting a RangeGlobalStep inside a global parent leads to failure to "reset" on each iteration:
```
gremlin> g.V().repeat(limit(1)).times(2)
==>v[1]
gremlin> g.V().repeat(union(limit(1))).times(2)
gremlin>
```
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4051,6 +4054,9 @@ g.V().valueMap().select('location').range(local, 1, 2).unfold() <3>
<2> `List<String>` for each vertex containing the second location.
<3> `String` for each vertex containing the second location (use `unfold()` to extract single elements from singleton collections).
+NOTE: When using `range()` inside <<repeat-step,`repeat()`>>, each repeat iteration maintains its own counter.
+See the <<repeat-step,repeat step documentation>> for examples and details.
+
Review Comment:
A similar call out for `skip()` is warranted here.
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
+ return false;
+ }
throw FastNoSuchElementException.instance();
}
long avail = traverser.bulk();
- if (this.counter.get() + avail <= this.low) {
+ if (counter.get() + avail <= this.low) {
// Will not surpass the low w/ this traverser. Skip and filter the whole thing.
- this.counter.getAndAdd(avail);
+ counter.getAndAdd(avail);
return false;
}
// Skip for the low and trim for the high. Both can happen at once.
long toSkip = 0;
- if (this.counter.get() < this.low) {
- toSkip = this.low - this.counter.get();
+ if (counter.get() < this.low) {
+ toSkip = this.low - counter.get();
}
long toTrim = 0;
- if (this.high != -1 && this.counter.get() + avail >= this.high) {
- toTrim = this.counter.get() + avail - this.high;
+ if (this.high != -1 && counter.get() + avail >= this.high) {
+ toTrim = counter.get() + avail - this.high;
}
long toEmit = avail - toSkip - toTrim;
- this.counter.getAndAdd(toSkip + toEmit);
+ counter.getAndAdd(toSkip + toEmit);
traverser.setBulk(toEmit);
return true;
}
+ private String getCounterKey(Traverser.Admin<S> traverser) {
+ List<String> counterKeyParts = new ArrayList<>();
+ Traversal.Admin<Object, Object> traversal = this.getTraversal();
+ if (traversal.getParent() instanceof RepeatStep) {
Review Comment:
Note above comment about recursively checking parents
##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java:
##########
@@ -131,7 +131,7 @@ public void shouldApplyStrategiesCorrectly() {
}
assertEquals(4, found);
//
- //System.out.println(traversal.explain().prettyPrint(160));
+ System.out.println(traversal.explain().prettyPrint(170));
Review Comment:
Was this an intentional change?
##########
tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphRepeatRangeGlobalTest.java:
##########
@@ -0,0 +1,759 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.tinkergraph.structure;
+
+import java.util.List;
+import java.util.function.Function;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.tinkerpop.gremlin.process.computer.Computer;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.RepeatUnrollStrategy;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+
+public class TinkerGraphRepeatRangeGlobalTest {
+ private static GraphTraversalSource gSource;
+ private static GraphTraversalSource gComputerSource;
+
+ @BeforeClass
+ public static void setup() {
+ gSource = TinkerGraph.open().traversal().withoutStrategies(RepeatUnrollStrategy.class);
+ load(gSource);
+ gComputerSource = gSource.withComputer(Computer.compute().workers(3));
+ }
+
+ @Test
+ public void testBasicRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows")
+ .limit(1).out("knows"));
+ }
+
+ @Test
+ public void testBasicRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(2).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(2).out("knows")
+ .limit(2).out("knows"));
+
+ }
+
+ @Test
+ public void testRepeatOutLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ // adding order inside repeat breaks things
+ .repeat(__.out("knows").limit(2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").limit(2)
+ .out("knows").limit(2));
+ }
+
+ @Test
+ public void testRepeatWithBothAndLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.both("knows").order().by("id").limit(3))
+ .times(2),
+ s -> s.V().has("id", "l3-0")
+ .both("knows").order().by("id").limit(3)
+ .both("knows").order().by("id").limit(3));
+ }
+
+ @Test
+ public void testRepeatWithFilterAndLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").has("id", P.neq("l4-3")).order().limit(2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").has("id", P.neq("l4-3")).order().limit(2)
+ .out("knows").has("id", P.neq("l4-3")).order().limit(2));
+ }
+
+ @Test
+ public void testChainedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").limit(1).out("knows")).times(2)
+ .repeat(__.order().by("id").limit(1).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows"));
+ }
+
+ @Test
+ public void testChainedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").limit(2).out("knows")).times(2)
+ .repeat(__.order().by("id").limit(3).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").limit(1).out("knows")
+ .repeat(__.order().by("id").limit(1).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).out("knows")
+ .order().by("id").limit(1).in("knows")
+ .order().by("id").limit(1).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").limit(2).out("knows")
+ .repeat(__.order().by("id").limit(3).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(2).out("knows")
+ .order().by("id").limit(3).in("knows")
+ .order().by("id").limit(3).in("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows")
+ .repeat(__.limit(1).in("knows")
+ .repeat(__.limit(1).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows")
+ .limit(1).in("knows")
+ .limit(1).out("knows")
+ .limit(1).out("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(2).out("knows")
+ .repeat(__.limit(3).in("knows")
+ .repeat(__.limit(4).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .limit(2).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(2).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows")
+ .limit(3).in("knows")
+ .limit(4).out("knows")
+ .limit(4).out("knows"));
+ }
+
+ @Test
+ public void testAggregateRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(1).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .limit(1).out("knows").aggregate("x")
+ .limit(1).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testAggregateRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.limit(3).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .limit(3).out("knows").aggregate("x")
+ .limit(3).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testUnionRepeatLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .repeat(__.limit(1)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .limit(1));
+ }
+
+ @Test
+ public void testUnionRepeatLimitIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .repeat(__.limit(3)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().limit(1), out().out().limit(1))
+ .limit(3));
+ }
+
+ @Test
+ public void testBasicRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows"));
+ }
+
+ @Test
+ public void testBasicRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 2).out("knows"))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 2).out("knows")
+ .range(0, 2).out("knows"));
+ }
+
+ @Test
+ public void testRepeatOutRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").range(0, 2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").range(0, 2)
+ .out("knows").range(0, 2));
+ }
+
+ @Test
+ public void testRepeatWithBothAndRange() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.both("knows").order().by("id").range(0, 3))
+ .times(2),
+ s -> s.V().has("id", "l3-0")
+ .both("knows").order().by("id").range(0, 3)
+ .both("knows").order().by("id").range(0, 3));
+ }
+
+ @Test
+ public void testRepeatWithFilterAndRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.out("knows").has("id", P.neq("l4-3")).order().range(0, 2))
+ .times(2),
+ s -> s.V().has("id", "l2-0")
+ .out("knows").has("id", P.neq("l4-3")).order().range(0, 2)
+ .out("knows").has("id", P.neq("l4-3")).order().range(0, 2));
+ }
+
+ @Test
+ public void testChainedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").range(0, 1).out("knows")).times(2)
+ .repeat(__.order().by("id").range(0, 1).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows"));
+ }
+
+ @Test
+ public void testChainedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l2-0")
+ .repeat(__.order().by("id").range(0, 2).out("knows")).times(2)
+ .repeat(__.order().by("id").range(0, 3).in("knows")).times(2),
+ s -> s.V().has("id", "l2-0")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").range(0, 1).out("knows")
+ .repeat(__.order().by("id").range(0, 1).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).out("knows")
+ .order().by("id").range(0, 1).in("knows")
+ .order().by("id").range(0, 1).in("knows"));
+ }
+
+ @Test
+ public void testNestedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l3-0")
+ .repeat(__.order().by("id").range(0, 2).out("knows")
+ .repeat(__.order().by("id").range(0, 3).in("knows"))
+ .times(2))
+ .times(2), s -> s.V().has("id", "l3-0")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 2).out("knows")
+ .order().by("id").range(0, 3).in("knows")
+ .order().by("id").range(0, 3).in("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows")
+ .repeat(__.range(0, 1).in("knows")
+ .repeat(__.range(0, 1).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).in("knows")
+ .range(0, 1).out("knows")
+ .range(0, 1).out("knows"));
+ }
+
+ @Test
+ public void testTripleNestedRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 2).out("knows")
+ .repeat(__.range(0, 3).in("knows")
+ .repeat(__.range(0, 4).out("knows"))
+ .times(2))
+ .times(2))
+ .times(2),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 2).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 2).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows")
+ .range(0, 3).in("knows")
+ .range(0, 4).out("knows")
+ .range(0, 4).out("knows"));
+ }
+
+ @Test
+ public void testAggregateRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 1).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 1).out("knows").aggregate("x")
+ .range(0, 1).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testAggregateRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .repeat(__.range(0, 3).out("knows").aggregate("x"))
+ .times(2)
+ .cap("x"),
+ s -> s.V().has("id", "l1-0")
+ .range(0, 3).out("knows").aggregate("x")
+ .range(0, 3).out("knows").aggregate("x")
+ .cap("x"));
+ }
+
+ @Test
+ public void testUnionRepeatRange() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .repeat(__.range(0, 1)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .range(0, 1));
+ }
+
+ @Test
+ public void testUnionRepeatRangeIncreasedLimit() {
+ testTraversals(s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .repeat(__.range(0, 3)).times(1),
+ s -> s.V().has("id", "l1-0")
+ .union(out().range(0, 1), out().out().range(0, 1))
+ .range(0, 3));
+ }
+
+ private void testTraversals(Function<GraphTraversalSource, GraphTraversal<Vertex, Vertex>> repeatFunction,
+ Function<GraphTraversalSource, GraphTraversal<Vertex, Vertex>> nonRepeatFunction) {
+ List<?> repeatTraversal = repeatFunction.apply(gSource).toList();
+ List<?> withComputerTraversal = repeatFunction.apply(gComputerSource).toList();
+ List<?> nonRepeatTraversal = nonRepeatFunction.apply(gSource).toList();
+ assertFalse(repeatTraversal.isEmpty());
+ assertTrue(CollectionUtils.isEqualCollection(repeatTraversal, nonRepeatTraversal));
+ // due to non-sequential processing of computer algorithm, can not assert equality but only size
+ assertEquals(repeatTraversal.size(), withComputerTraversal.size());
+ }
+
+ private static void load(GraphTraversalSource g) {
Review Comment:
Do you think there would be value in giving this graph a name and adding it to TinkerFactory such that it is reusable elsewhere, or is it too specific for the exact behaviour you are trying to test here?
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,181 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).times(2).values("name")
Review Comment:
Nit: The usages of `withoutStrategies(RepeatUnrollStrategy)` in these tests seems redundant following the resolution of https://issues.apache.org/jira/browse/TINKERPOP-3192
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
Review Comment:
I'm curious if we can get away with dropping this if statement altogether and always returning false instead of throwing a FastNoSuchElementException regardless of if this step is nested in a repeat. A quick test shows that with the exception of `g_V_playlist_paths` in Paths.feature (which seems to hang indefinitely), all of the remaining feature tests are unaffected by such a change. I'm not quite sure why that one scenario is failing, but that may be a path to a preferable solution if it can be resolved.
It's notable that most filter steps (especially TailGlobalStep) don't throw NoSuchElementExceptions and instead solely rely on returning false from `filter()` to indicate a result should be filtered.
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,23 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit() and range() inside repeat()
Review Comment:
Nit: include `skip()` as well. It also may be worth clarifying that this only affects the globally scoped versions of these steps, as the local forms implicitly reset on each traverser.
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,38 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() and range() Semantics in repeat()
+
+The semantics of `limit()` and `range()` steps inside `repeat()` has been modified to ensure consistent semantics across
Review Comment:
Nit: skip()
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
Review Comment:
I'm a bit confused by this sentence (may be due to my limited understanding of loops tracking in Traversers). I'm not understanding when a Traverser would support nested loops but not single loops. Just looking at the names of the traversers, all of the NL traversers also contain SL. Additionally, the way RepeatStep adds requirements, any Traversal with NL requirements will always contain SL requirements as well.
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -129,6 +170,9 @@ public boolean equals(final Object other) {
@Override
public Set<TraverserRequirement> getRequirements() {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
Review Comment:
The tests all seem to pass with this code removed (I only ran tests through tinkergraph-gremlin but that should be sufficient). The getRequirements() method in RepeatStep should already take care of these cases, as the presence of a single RepeatStep in a traversal will add a `SINGLE_LOOP` requirement, and if a RepeatStep wraps a child which itself contains a repeat, it will add `NESTED_LOOP`. That alone should guarantee these requirements will be present anytime it is needed for this step.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441455833
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
Review Comment:
> I think it's b/c even though NL traversers contain SL, implementation wise they extend but overrode the SL logic, so essentially it is one or the other?
This is exactly why. The NL traversers all extend SL traversers but override all `loops` related methods to reference the nested loop stack and the single loop counter is essentially unused.
Yes all NL traversers do support SL but do so using the NL stack data structure, ignoring the SL loop counter.
I've modified the javadoc to be hopefully less confusing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441450258
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4051,6 +4054,9 @@ g.V().valueMap().select('location').range(local, 1, 2).unfold() <3>
<2> `List<String>` for each vertex containing the second location.
<3> `String` for each vertex containing the second location (use `unfold()` to extract single elements from singleton collections).
+NOTE: When using `range()` inside <<repeat-step,`repeat()`>>, each repeat iteration maintains its own counter.
+See the <<repeat-step,repeat step documentation>> for examples and details.
+
Review Comment:
Added callout for skip
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441452551
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,38 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() and range() Semantics in repeat()
+
+The semantics of `limit()` and `range()` steps inside `repeat()` has been modified to ensure consistent semantics across
Review Comment:
Added skip to documentation and added 'globally-scoped' to the description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446780899
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,239 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
Review Comment:
There's actually a nested traversal for range:
```
Scenario: g_VX5X_repeatXrangeX0_1X_in_repeatXrangeX0_1X_inX_timesX1XX_timesX1X_valuesXnameX
Given the modern graph
And using the parameter vid5 defined as "v[ripple].id"
And the traversal of
"""
g.V(vid5).repeat(range(0, 1).in().repeat(range(0, 1).in()).times(1)).times(1).values("name")
"""
When iterated to list
Then the result should be unordered
| result |
| marko |
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445961437
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
Review Comment:
is this correct? why is it returning a `VertexProperty` here when you did `values('name')`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438408309
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,181 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).times(2).values("name")
Review Comment:
Removed the `withoutStrategies`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2437317856
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
+ * Implementations are expected to override either the single or nested loop functions depending on the type of loop
+ * they are supporting.
+ * <p>
+ * Note: it would be nice to separate the {@link TraverserRequirement#SINGLE_LOOP} vs {@link TraverserRequirement#NESTED_LOOP}
+ * logic into different traverser interfaces in the future however the current {@link Traverser} class hierarchy makes
+ * that difficult as {@link Traverser}s that support nested loops extend from {@link Traverser}s that support single
+ * loops but override all single loop logic with nested loop logic.
+ */
+public interface NL_SL_Traverser<T> extends Traverser.Admin<T> {
+ /**
+ * @return the supported loop type - either {@link TraverserRequirement#NESTED_LOOP} or {@link TraverserRequirement#SINGLE_LOOP}
+ */
+ TraverserRequirement getLoopRequirement();
+
+ // NESTED LOOPS
+
+ /**
+ * Override this method to support nested loops.
+ *
+ * @return the {@link Stack} of {@link LabelledCounter} which holds the nested loops.
+ */
+ default Stack<LabelledCounter> getNestedLoops() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Override this method to support nested loops.
+ *
+ * @return the {@link ReferenceMap} where key=loop name and value=reference to the {@link LabelledCounter}.
+ */
+ default ReferenceMap getNestedLoopNames() {
+ throw new UnsupportedOperationException();
+ }
+
+ // SINGLE LOOPS
+
+ /**
+ * Override this method to support single loop.
+ *
+ * @return the single loop count.
+ */
+ default short getSingleLoopCount() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Override this method to support single loop. Sets the single loop count.
+ */
+ default void setSingleLoopCount(short loops) {
Review Comment:
Nit: check for places `final` can be added in this interface
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2437312558
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
Review Comment:
It might also be good to have a query that has the limit inside a TraversalParent inside a repeat(). like:
`g.V().repeat(__.both().where(__.has("name").limit(1))).times(2)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445970437
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+gremlin>
+// 3.7.4 - modern graph examples demonstrating too many results with skip in repeat due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(out().skip(1)).times(2).values('name')
+==>ripple
+==>lop
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+
+// 3.8.0 - grateful dead graph examples producing results as limit counters tracked per iteration
+gremlin> g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+==>[name:[vp[name->HURTS ME TOO]]]
+==>[name:[vp[name->BLACK THROATED WIND]]]
+gremlin> g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
+==>DEAL
+==>WOMEN ARE SMARTER
+// 3.8.0 - modern graph examples demonstrating consistent skip semantics
+gremlin> g.V(1).repeat(out().skip(1)).times(2).values('name')
+==>lop
+gremlin> g.V(1).out().skip(1).out().skip(1).values('name')
+==>lop
+----
+
+This change ensures that globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` now use per-iteration
+counters, making the behavior consistent with manually unrolled traversals. Locally-scoped variants of these steps are
+not affected by these changes.
Review Comment:
This section kinda ends without much explanation as to the impact here. What should folks be considering as they upgrade? Like, what do they need to consider about their code as a result of all you've described?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446005843
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
have you given any thought to what the performance impact is? i'm curious what we could compare between versions to get some sort of idea what we could be facing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446770010
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,25 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit(), skip(), range() inside repeat()
+
+When using globally-scoped (default scope) `limit()`, `skip()`, or `range()` steps inside `repeat()`, each iteration of
+the repeat gets its own counter, ensuring consistent behavior across iterations:
+
+[gremlin-groovy,grateful-dead]
+----
+g.V().has('name','JAM').repeat(out('followedBy').limit(2)).times(3) <1>
+g.V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2) <2>
Review Comment:
Changed to `__.in`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446780899
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,239 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
Review Comment:
There's actually a nested traversal for range:
```
Scenario: g_VX5X_repeatXrangeX0_1X_in_repeatXrangeX0_1X_inX_timesX1XX_timesX1X_valuesXnameX
Given the modern graph
And using the parameter vid5 defined as "v[ripple].id"
And the traversal of
"""
g.V(vid5).repeat(range(0, 1).in().repeat(range(0, 1).in()).times(1)).times(1).values("name")
"""
When iterated to list
Then the result should be unordered
| result |
| marko |
```
Each `range` step in this example has its own set of iteration counters in isolation from the other.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438301363
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/traverser/NL_SL_Traverser.java:
##########
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.process.traversal.traverser;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Stack;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.tinkerpop.gremlin.process.traversal.Traverser;
+import org.apache.tinkerpop.gremlin.process.traversal.traverser.util.LabelledCounter;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.NESTED_LOOP;
+import static org.apache.tinkerpop.gremlin.process.traversal.traverser.TraverserRequirement.SINGLE_LOOP;
+
+/**
+ * Intermediate helper interface for {@link Traverser}s that support single OR nested loops (but not both).
Review Comment:
I think it's b/c even though NL traversers contain SL, implementation wise they extend but overrode the SL logic, so essentially it is one or the other?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2438406806
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,181 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).times(2).values("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_repeatXlimitX1X_inX_untilXloopsXisX2XXX_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).repeat(limit(1).in()).until(loops().is(2)).values("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | result |
+ | marko |
+
+ Scenario: g_withoutStrategiesXRepeatUnrollStrategyX_VX5X_limitX1X_in_limitX1X_in_valuesXnameX
+ Given the modern graph
+ And using the parameter vid5 defined as "v[ripple].id"
+ And the traversal of
+ """
+ g.withoutStrategies(RepeatUnrollStrategy).V(vid5).limit(1).in().limit(1).in().values("name")
Review Comment:
I ended up removing all usages of `withoutStrategies(RepeatUnrollStrategy)` because `range` is no longer unrolled by that strategy
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446774109
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
+gremlin>
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','DRUMS').repeat(in('followedBy').range(1,3)).times(2).values('name')
Review Comment:
Changed to `__.in`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446773200
##########
docs/src/dev/provider/gremlin-semantics.asciidoc:
##########
@@ -2034,6 +2034,14 @@ message containing: `The repeat()-traversal was not defined`.
- Nested repeats and loop names:
- Nested `repeat()` steps maintain separate loop counters. Use `repeat("a", ...)` and `loops("a")` to reference a
specific counter inside nested loops.
+- Range steps (`limit()`, `skip()`, `range()`) in `repeat()`:
Review Comment:
Removed change to semantics doc in favour of better description and examples in the traversal reference doc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446767752
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
Review Comment:
Changed to remove reference to 'counters' and instead referred to 'state'. Also changed 'globally-scoped' to `Scope.global`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445920376
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4051,6 +4054,9 @@ g.V().valueMap().select('location').range(local, 1, 2).unfold() <3>
<2> `List<String>` for each vertex containing the second location.
<3> `String` for each vertex containing the second location (use `unfold()` to extract single elements from singleton collections).
+NOTE: When using globally-scoped `range()` inside <<repeat-step,`repeat()`>>, each repeat iteration maintains its own counter.
Review Comment:
If I pretend I'm a new or casual Gremlin user I'm not sure that these `NOTE` callouts are helpful. I'm not sure I'd understand them and they seem to carry context that is implicit to this change that isn't clearly defined. Consider my comments at https://github.com/apache/tinkerpop/pull/3241/files#r2445906983 in deciding what happens here next I guess.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445965186
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
Review Comment:
First paragraph is a little dense. "counters" (global or otherwise) isn't a term we've really promoted anywhere so i'm not sure anyone will understand what this means. A bit more introductory defining, maybe in conjunction with your examples, would better get the point across?
i think when you refer to "globally-scoped" steps you could also define them clearly to mean those that are called with`Scope.global` which includes their default usage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "kenhuuu (via GitHub)" <gi...@apache.org>.
kenhuuu commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2437315993
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
+ return false;
+ }
throw FastNoSuchElementException.instance();
}
long avail = traverser.bulk();
- if (this.counter.get() + avail <= this.low) {
+ if (counter.get() + avail <= this.low) {
// Will not surpass the low w/ this traverser. Skip and filter the whole thing.
- this.counter.getAndAdd(avail);
+ counter.getAndAdd(avail);
return false;
}
// Skip for the low and trim for the high. Both can happen at once.
long toSkip = 0;
- if (this.counter.get() < this.low) {
- toSkip = this.low - this.counter.get();
+ if (counter.get() < this.low) {
+ toSkip = this.low - counter.get();
}
long toTrim = 0;
- if (this.high != -1 && this.counter.get() + avail >= this.high) {
- toTrim = this.counter.get() + avail - this.high;
+ if (this.high != -1 && counter.get() + avail >= this.high) {
+ toTrim = counter.get() + avail - this.high;
}
long toEmit = avail - toSkip - toTrim;
- this.counter.getAndAdd(toSkip + toEmit);
+ counter.getAndAdd(toSkip + toEmit);
traverser.setBulk(toEmit);
return true;
}
+ private String getCounterKey(Traverser.Admin<S> traverser) {
Review Comment:
Nit: check for `final`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441452394
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4162,6 +4168,23 @@ In OLAP, where the atomic unit of computing is the vertex and its local "star gr
anonymous traversals do not leave the confines of the vertex's star graph. In other words, they can not traverse to
an adjacent vertex's properties or edges.
+==== Using limit() and range() inside repeat()
Review Comment:
Added skip to documentation and added 'globally-scoped' to the description
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441453208
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -129,6 +170,9 @@ public boolean equals(final Object other) {
@Override
public Set<TraverserRequirement> getRequirements() {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
Review Comment:
I reverted the requirements back to just BULK. Not sure why I had originally thought tests would fail otherwise.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441108954
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -55,40 +64,72 @@ public RangeGlobalStep(final Traversal.Admin traversal, final long low, final lo
protected boolean filter(final Traverser.Admin<S> traverser) {
if (this.bypass) return true;
- if (this.high != -1 && this.counter.get() >= this.high) {
+ final String counterKey = getCounterKey(traverser);
+ final AtomicLong counter = counters.computeIfAbsent(counterKey, k -> new AtomicLong(0L));
+
+ if (this.high != -1 && counter.get() >= this.high) {
+ if (this.getTraversal().getParent() instanceof RepeatStep) {
Review Comment:
I've changed the check to move upwards until the root and added feature test for limit in union in repeat. I prefer to leave the check in to reduce potential backwards compatibility breakage since we know something is going wrong with the Paths.feature test when it is removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2441460864
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
In general yes nested repeats can be less performant than the unrolled equivalent but that was the case even prior to this change. I believe that is the reason for creating the RepeatUnrollStrategy which will optimize by unrolling simple repeat traversals if possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2453441518
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -39,7 +45,10 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements RangeGlob
private long low;
private long high;
- private AtomicLong counter = new AtomicLong(0l);
+ /**
+ * If this range step is used inside a loop there can be multiple counters, otherwise there should only be one
+ */
+ private Map<String, AtomicLong> counters = new HashMap<>();
Review Comment:
After benchmarking I found that `limit` and `range` without `repeat` performance decreased slightly (approx 2%) but `skip` had a larger impact (approx 15%) so I created a follow up PR to improve performance: https://github.com/apache/tinkerpop/pull/3251.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446027978
##########
gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/filter/Range.feature:
##########
@@ -411,3 +411,239 @@ Feature: Step - range()
| result |
| l[d[2].i] |
| l[d[5].i] |
+
+ Scenario: g_VX5X_repeatXlimitX1X_inX_timesX2X_valuesXnameX
Review Comment:
I'm not thinking about this too deeply, but I don't notice any test cases here that use nested `repeat` + `range/limit` combinations. What is the implication for that usage in relation to this change?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "andreachild (via GitHub)" <gi...@apache.org>.
andreachild commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2446773903
##########
docs/src/reference/the-traversal.asciidoc:
##########
@@ -4051,6 +4054,9 @@ g.V().valueMap().select('location').range(local, 1, 2).unfold() <3>
<2> `List<String>` for each vertex containing the second location.
<3> `String` for each vertex containing the second location (use `unfold()` to extract single elements from singleton collections).
+NOTE: When using globally-scoped `range()` inside <<repeat-step,`repeat()`>>, each repeat iteration maintains its own counter.
Review Comment:
Removed the NOTE callouts in the individual steps in favour of examples using these steps inside repeat as part of the repeat step documentation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Change range in repeat to track counters per iteration [tinkerpop]
Posted by "spmallette (via GitHub)" <gi...@apache.org>.
spmallette commented on code in PR #3241:
URL: https://github.com/apache/tinkerpop/pull/3241#discussion_r2445957311
##########
docs/src/upgrade/release-3.8.x.asciidoc:
##########
@@ -830,6 +843,46 @@ g.V().repeat(both()).times(2).dedup()
See: link:https://issues.apache.org/jira/browse/TINKERPOP-3192[TINKERPOP-3192]
+==== Modified limit() skip() range() Semantics in repeat()
+
+The semantics of globally-scoped `limit()`, `skip()`, and `range()` steps inside `repeat()` have been modified to ensure
+consistent semantics across repeat iterations.Previously, these steps would track global counters, leading to unexpected
+behavior where subsequent iterations of `limit()` and `range()` would filter all traversers as previous iterations
+reached the global limits. In the case of `skip()`, traversers would be passed to subsequent iterations when they should
+have been filtered. As of 3.8.0 the counters are tracked per iteration.
+
+[source,groovy]
+----
+// 3.7.4 - grateful dead graph examples producing no results due to global counters
+gremlin> g.withoutStrategies(RepeatUnrollStrategy).V().has('name','JAM').repeat(out('followedBy').limit(2)).times(2).values('name')
Review Comment:
only a handful of people will understand why you removed `RepeatUnrollStrategy` here. i think you need more introduction and explanation if this has to be used to demonstrate the differences between versions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org