Cole-Greer commented on code in PR #3251:
URL: https://github.com/apache/tinkerpop/pull/3251#discussion_r2456032981


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java:
##########
@@ -157,10 +163,26 @@ public void processAllStarts() {
 
     }
 
+    private AtomicLong getCounter(final Traverser.Admin<S> traverser) {
+        if (isInsideLoop()) {
+            final String counterKey = getCounterKey(traverser);
+            return loopCounters.computeIfAbsent(counterKey, k -> new 
AtomicLong(0L));
+        } else {
+            return this.singleCounter;
+        }
+    }
+
+    private boolean isInsideLoop() {

Review Comment:
   There is some risk that if this method is called before a traversal is 
finalized (for example before "this" traversal is added to a new parent), it 
may store an incorrect state in `this.insideLoop` which appears unrecoverable. 
It looks to be handled properly here, but could benefit from a comment warning 
future devs of such considerations.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to