[ 
https://issues.apache.org/jira/browse/TINKERPOP-3201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18033389#comment-18033389
 ] 

ASF GitHub Bot commented on TINKERPOP-3201:
-------------------------------------------

andreachild commented on code in PR #3248:
URL: https://github.com/apache/tinkerpop/pull/3248#discussion_r2467531060


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java:
##########
@@ -58,9 +59,13 @@ public Traverser.Admin<S> processNextStart() {
             // If we are bypassing this step, let everything through.
             return this.starts.next();
         } else {
+            if (this.tail.isEmpty()) {
+                consuming = true;
+            }
             // Pull everything available before we start delivering from the 
tail buffer.
-            if (this.starts.hasNext()) {
+            if (consuming && this.starts.hasNext()) {
                 this.starts.forEachRemaining(this::addTail);
+                consuming = false;

Review Comment:
   Can this be replaced with just a check for `tail.isEmpty()`?
   ```suggestion
               if (this.tail.isEmpty() && this.starts.hasNext()) {
                   this.starts.forEachRemaining(this::addTail);
   ```





> Fix tail inside repeat
> ----------------------
>
>                 Key: TINKERPOP-3201
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3201
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.8.0
>            Reporter: Ken Hu
>            Priority: Major
>             Fix For: 3.8.0
>
>
> tail() step inside repeat() is not properly resetting per iteration.
> Consider the following queries on the modern graph on 3.7.x
> {code:java}
> gremlin> 
> g.withoutStrategies(RepeatUnrollStrategy).V(1).repeat(__.both().order().tail(2)).times(2)
> ==>v[4]
> ==>v[6]
> {code}
> {code:java}
> gremlin> g.V(1).both().order().tail(2).both().order().tail(2)
> ==>v[5]
> ==>v[6]
> {code}
> The unrolled version doesn't match the repeat() version because tail() is 
> recalculated on each call to processNextStart(). The tail() is being 
> calculated too frequently even though there are still output traversers 
> remaining from the previous calculation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to