Repository: tinkerpop Updated Branches: refs/heads/master c25033175 -> cc0c06f41
remove excess bulk in tail buffer Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6d293942 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6d293942 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6d293942 Branch: refs/heads/master Commit: 6d29394225ff49ad12582d8e8e5bfc7b07e9ccfa Parents: 4571061 Author: Jason Plurad <plur...@us.ibm.com> Authored: Sat Jul 30 00:04:54 2016 -0400 Committer: Jason Plurad <plur...@us.ibm.com> Committed: Fri Aug 12 08:29:01 2016 -0400 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../traversal/step/filter/TailGlobalStep.java | 5 ++++- .../traversal/step/filter/GroovyTailTest.groovy | 5 +++++ .../process/traversal/step/filter/TailTest.java | 18 ++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d293942/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 975f6cf..fefffb0 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -29,6 +29,7 @@ TinkerPop 3.1.4 (NOT OFFICIALLY RELEASED YET) * Fixed a potential leak of a `ReferenceCounted` resource in Gremlin Server. * Renamed distributions to make the prefix "apache-tinkerpop-" as opposed to just "apache-". * Fixed a problem (previously thought resolved on 3.1.3) causing Gremlin Server to lock up when parallel requests were submitted on the same session if those parallel requests included a script that blocked indefinitely. +* Fixed bug in `TailGlobalStep` where excess bulk was not accounted for correctly. [[release-3-1-3]] TinkerPop 3.1.3 (Release Date: July 18, 2016) http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d293942/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java index 19d3d95..33c7c22 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailGlobalStep.java @@ -64,8 +64,11 @@ public final class TailGlobalStep<S> extends AbstractStep<S, S> implements Bypas final Traverser.Admin<S> oldest = this.tail.pop(); // Trim any excess from the oldest traverser. final long excess = this.tailBulk - this.limit; - if (excess > 0) + if (excess > 0) { oldest.setBulk(oldest.bulk() - excess); + // Account for the loss of excess in the tail buffer + this.tailBulk -= excess; + } // Account for the loss of bulk in the tail buffer as we emit the oldest traverser. this.tailBulk -= oldest.bulk(); return oldest; http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d293942/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy ---------------------------------------------------------------------- diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy index 50f4d96..7fac07e 100644 --- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy +++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyTailTest.groovy @@ -65,6 +65,11 @@ public abstract class GroovyTailTest { } @Override + public Traversal<Vertex, Long> get_g_V_repeatXin_outX_timesX3X_tailX7X_count() { + TraversalScriptHelper.compute("g.V.repeat(__.in().out()).times(3).tail(7).count()",g) + } + + @Override public Traversal<Vertex, List<String>> get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X() { TraversalScriptHelper.compute("g.V.as('a').out.as('a').out.as('a').select('a').by(unfold().values('name').fold).tail(local, 2)",g) } http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6d293942/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailTest.java ---------------------------------------------------------------------- diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailTest.java index 21bdbe6..738964c 100644 --- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailTest.java +++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/TailTest.java @@ -28,6 +28,7 @@ import org.junit.runner.RunWith; import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both; +import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.limit; import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.unfold; import static org.apache.tinkerpop.gremlin.process.traversal.Scope.global; @@ -35,6 +36,7 @@ import static org.apache.tinkerpop.gremlin.process.traversal.Scope.local; import static org.junit.Assert.assertEquals; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -58,6 +60,8 @@ public abstract class TailTest extends AbstractGremlinProcessTest { public abstract Traversal<Vertex, Vertex> get_g_V_repeatXbothX_timesX3X_tailX7X(); + public abstract Traversal<Vertex, Long> get_g_V_repeatXin_outX_timesX3X_tailX7X_count(); + public abstract Traversal<Vertex, List<String>> get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X(); public abstract Traversal<Vertex, String> get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_1X(); @@ -120,6 +124,15 @@ public abstract class TailTest extends AbstractGremlinProcessTest { assertEquals(7, counter); } + /** Scenario: Global scope, using repeat (excess BULK) */ + @Test + @LoadGraphWith(MODERN) + public void g_V_repeatXin_outX_timesX3X_tailX7X_count() { + final Traversal<Vertex, Long> traversal = get_g_V_repeatXin_outX_timesX3X_tailX7X_count(); + printTraversalForm(traversal); + checkResults(Collections.singletonList(7L), traversal); + } + /** Scenario: Local scope, List input, N>1 */ @Test @LoadGraphWith(MODERN) @@ -221,6 +234,11 @@ public abstract class TailTest extends AbstractGremlinProcessTest { } @Override + public Traversal<Vertex, Long> get_g_V_repeatXin_outX_timesX3X_tailX7X_count() { + return g.V().repeat(in().out()).times(3).tail(7).count(); + } + + @Override public Traversal<Vertex, List<String>> get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X() { return g.V().as("a").out().as("a").out().as("a").<List<String>>select("a").by(unfold().values("name").fold()).tail(local, 2); }