This is an automated email from the ASF dual-hosted git repository. colegreer pushed a commit to branch repeatLimit in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 2c4b4e689659e061ffbb0a0f08c50add3df5b866 Author: Andrea Child <andrea.ch...@improving.com> AuthorDate: Fri Aug 29 16:24:47 2025 -0700 Added more tests. --- .../traversal/step/filter/RangeGlobalStep.java | 1 + .../tinkergraph/structure/TinkerGraphPlayTest.java | 117 +++++++++++++++++++++ 2 files changed, 118 insertions(+) diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java index e02c572c3c..2b7c7431c7 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/RangeGlobalStep.java @@ -79,6 +79,7 @@ public final class RangeGlobalStep<S> extends FilterStep<S> implements Ranging, Traversal.Admin t = this.traversal; while (!t.isRoot()) { TraversalParent pt = t.getParent(); + // TODO: account scenario where parent is not repeat step? Step<?, ?> ps = pt.asStep(); String pid = ps.getId(); sb.append(pid).append(":"); diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java index e6ccff6d8d..af6485be9e 100644 --- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java +++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java @@ -85,6 +85,18 @@ public class TinkerGraphPlayTest { assertEquals(toListAndPrint("basic", basic), toListAndPrint("basicUnfolded", basicUnfolded)); } + @Test + public void testBasicRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Path> basic = g.V().has("id", "l1-0") + .repeat(__.limit(2).out("knows")) + .times(2).path().by("id"); + GraphTraversal<Vertex, Path> basicUnfolded = g.V().has("id", "l1-0") + .limit(2).out("knows") + .limit(2).out("knows") + .path().by("id"); + assertEquals(toListAndPrint("basic", basic), toListAndPrint("basicUnfolded", basicUnfolded)); + } + @Test public void testChainedRepeatLimit() { GraphTraversal<Vertex, Path> chained = g.V().has("id", "l2-0") @@ -100,6 +112,21 @@ public class TinkerGraphPlayTest { assertEquals(toListAndPrint("chained", chained), toListAndPrint("chainedUnfolded", chainedUnfolded)); } + @Test + public void testChainedRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Path> chained = g.V().has("id", "l2-0") + .repeat(__.limit(2).out("knows")).times(2) + .repeat(__.limit(3).in("knows")).times(2) + .path().by("id"); + GraphTraversal<Vertex, Path> chainedUnfolded = g.V().has("id", "l2-0") + .limit(2).out("knows") + .limit(2).out("knows") + .limit(3).in("knows") + .limit(3).in("knows") + .path().by("id"); + assertEquals(toListAndPrint("chained", chained), toListAndPrint("chainedUnfolded", chainedUnfolded)); + } + @Test public void testNestedRepeatLimit() { GraphTraversal<Vertex, Path> nested = g.V().has("id", "l3-0") @@ -135,6 +162,41 @@ public class TinkerGraphPlayTest { assertEquals(toListAndPrint("nested2", nested2), toListAndPrint("nested2Unfolded", nested2Unfolded)); } + @Test + public void testNestedRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Path> nested = g.V().has("id", "l3-0") + .repeat(__.limit(2).out("knows") + .repeat(__.limit(3).in("knows")) + .times(2)) + .times(2) + .path().by("id"); + GraphTraversal<Vertex, Path> nestedUnfolded = g.V().has("id", "l3-0") + .limit(2).out("knows") + .limit(3).in("knows") + .limit(3).in("knows") + .limit(2).out("knows") + .limit(3).in("knows") + .limit(3).in("knows") + .path().by("id"); + assertEquals(toListAndPrint("nested", nested), toListAndPrint("nestedUnfolded", nestedUnfolded)); + + GraphTraversal<Vertex, Path> nested2 = g.V().has("id", "l3-0").out("knows"). + repeat(__.limit(1).out("knows") + .repeat(__.limit(1).in("knows")) + .times(2)). + times(2) + .path().by("id"); + GraphTraversal<Vertex, Path> nested2Unfolded = g.V().has("id", "l3-0").out("knows") + .limit(1).out("knows") + .limit(1).in("knows") + .limit(1).in("knows") + .limit(1).out("knows") + .limit(1).in("knows") + .limit(1).in("knows") + .path().by("id"); + assertEquals(toListAndPrint("nested2", nested2), toListAndPrint("nested2Unfolded", nested2Unfolded)); + } + @Test public void testTripleNestedRepeatLimit() { GraphTraversal<Vertex, Path> tripleNested = g.V().has("id", "l1-0") @@ -164,6 +226,35 @@ public class TinkerGraphPlayTest { assertEquals(toListAndPrint("tripleNested", tripleNested), toListAndPrint("tripleNestedUnfolded", tripleNestedUnfolded)); } + @Test + public void testTripleNestedRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Path> tripleNested = g.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) + .path().by("id"); + GraphTraversal<Vertex, Path> tripleNestedUnfolded = g.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") + .path().by("id"); + assertEquals(toListAndPrint("tripleNested", tripleNested), toListAndPrint("tripleNestedUnfolded", tripleNestedUnfolded)); + } + @Test public void testAggregateRepeatLimit() { GraphTraversal<Vertex, Object> aggregate = g.V().has("id", "l1-0") @@ -177,6 +268,19 @@ public class TinkerGraphPlayTest { assertEquals(toListAndPrint("aggregate", aggregate), toListAndPrint("aggregateUnfolded", aggregateUnfolded)); } + @Test + public void testAggregateRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Object> aggregate = g.V().has("id", "l1-0") + .repeat(__.limit(3).out("knows").aggregate("x")) + .times(2) + .cap("x"); + GraphTraversal<Vertex, Object> aggregateUnfolded = g.V().has("id", "l1-0") + .limit(3).out("knows").aggregate("x") + .limit(3).out("knows").aggregate("x") + .cap("x"); + assertEquals(toListAndPrint("aggregate", aggregate), toListAndPrint("aggregateUnfolded", aggregateUnfolded)); + } + @Test public void testUnionRepeatLimit() { GraphTraversal<Vertex, Path> union = g.V().has("id", "l1-0") @@ -189,6 +293,19 @@ public class TinkerGraphPlayTest { .path().by("id"); assertEquals(toListAndPrint("union", union), toListAndPrint("unionUnfolded", unionUnfolded)); } + + @Test + public void testUnionRepeatLimitIncreasedLimit() { + GraphTraversal<Vertex, Path> union = g.V().has("id", "l1-0") + .union(out().limit(1), out().out().limit(1)) + .repeat(__.limit(3)).times(1) + .path().by("id"); + GraphTraversal<Vertex, Path> unionUnfolded = g.V().has("id", "l1-0") + .union(out().limit(1), out().out().limit(1)) + .limit(3) + .path().by("id"); + assertEquals(toListAndPrint("union", union), toListAndPrint("unionUnfolded", unionUnfolded)); + } private List toListAndPrint(String header, GraphTraversal t) { System.out.println("=====" + header + "===================================");