Skip to content

Commit b300d63

Browse files
committed
Minor fix for null with olap and tests for repeat() fail conditions CTR
1 parent a4a506d commit b300d63

File tree

7 files changed

+55
-2
lines changed
  • docs/src/reference
  • gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch
  • gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin
  • gremlin-go/driver/cucumber
  • gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber
  • gremlin-python/src/main/python/radish
  • gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/branch

7 files changed

+55
-2
lines changed

docs/src/reference/the-traversal.asciidoc

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,8 +3969,8 @@ an adjacent vertex's properties or edges.
39693969
39703970
*Additional References*
39713971
3972-
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#repeat(org.apache.tinkerpop.gremlin.process.traversal.Traversal)++[`repeat(Traversal)`]
3973-
3972+
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#repeat(org.apache.tinkerpop.gremlin.process.traversal.Traversal)++[`repeat(Traversal)`],
3973+
<<emit-step, emit>>, <<times-step, times()>>, <<until-step,until()>>,
39743974
link:++https://tinkerpop.apache.org/docs/x.y.z/recipes/#looping++[`Looping Recipes`]
39753975
39763976
[[replace-step]]
@@ -4728,6 +4728,17 @@ yield `false`.
47284728
47294729
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#timeLimit(long)++[`timeLimit(long)`]
47304730
4731+
[[times-step]]
4732+
=== Times Step
4733+
4734+
The `times`-step is not an actual step, but is instead a step modulator for `<<repeat-step,repeat()>>` (find more
4735+
documentation on the `times()` there).
4736+
4737+
*Additional References*
4738+
4739+
link:++https://tinkerpop.apache.org/javadocs/x.y.z/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#times(int)++[`until(Predicate)`],
4740+
`<<emit-step,emit()>>`, `<<repeat-step,repeat()>>`, `<<until-step,until()>>`
4741+
47314742
[[to-step]]
47324743
=== To Step
47334744

gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatStep.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ private final String emitString() {
160160

161161
@Override
162162
public RepeatStep<S> clone() {
163+
if (null == this.repeatTraversal)
164+
throw new IllegalStateException("The repeat()-traversal was not defined: " + this);
165+
163166
final RepeatStep<S> clone = (RepeatStep<S>) super.clone();
164167
clone.repeatTraversal = this.repeatTraversal.clone();
165168
if (null != this.untilTraversal)

gremlin-dotnet/test/Gremlin.Net.IntegrationTest/Gherkin/Gremlin.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ private static IDictionary<string, List<Func<GraphTraversalSource, IDictionary<s
116116
{"g_VX1X_repeatXrepeatXunionXout_uses_out_traversesXX_whereXloops_isX0X_timesX1X_timeX2X_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid1"]).Repeat(__.Repeat(__.Union<object>(__.Out("uses"),__.Out("traverses")).Where(__.Loops().Is(0))).Times(1)).Times(2).Values<object>("name")}},
117117
{"g_V_repeatXa_outXknows_repeatXb_outXcreatedX_filterXloops_isX0XX_emit_lang", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Repeat("a",__.Out("knows").Repeat("b",__.Out("created").Filter(__.Loops("a").Is(0))).Emit()).Emit().Values<object>("lang")}},
118118
{"g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V(p["vid6"]).Repeat("a",__.Both("created").SimplePath()).Emit(__.Repeat("b",__.Both("knows")).Until(__.Loops("b").As("b").Where(__.Loops("a").As("b"))).Has("name","vadas")).Dedup().Values<object>("name")}},
119+
{"g_V_emit", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Emit()}},
120+
{"g_V_untilXidentityX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Until(__.Identity())}},
121+
{"g_V_timesX5X", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.V().Times(5)}},
119122
{"g_unionXX", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>()}},
120123
{"g_unionXV_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V().Values<object>("name"))}},
121124
{"g_unionXVXv1X_VX4XX_name", new List<Func<GraphTraversalSource, IDictionary<string, object>, ITraversal>> {(g,p) =>g.Union<object>(__.V((Vertex) p["v1"]),__.V((Vertex) p["v4"])).Values<object>("name")}},

gremlin-go/driver/cucumber/gremlin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ var translationMap = map[string][]func(g *gremlingo.GraphTraversalSource, p map[
8787
"g_VX1X_repeatXrepeatXunionXout_uses_out_traversesXX_whereXloops_isX0X_timesX1X_timeX2X_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid1"]).Repeat(gremlingo.T__.Repeat(gremlingo.T__.Union(gremlingo.T__.Out("uses"), gremlingo.T__.Out("traverses")).Where(gremlingo.T__.Loops().Is(0))).Times(1)).Times(2).Values("name")}},
8888
"g_V_repeatXa_outXknows_repeatXb_outXcreatedX_filterXloops_isX0XX_emit_lang": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Repeat("a", gremlingo.T__.Out("knows").Repeat("b", gremlingo.T__.Out("created").Filter(gremlingo.T__.Loops("a").Is(0))).Emit()).Emit().Values("lang")}},
8989
"g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V(p["vid6"]).Repeat("a", gremlingo.T__.Both("created").SimplePath()).Emit(gremlingo.T__.Repeat("b", gremlingo.T__.Both("knows")).Until(gremlingo.T__.Loops("b").As("b").Where(gremlingo.T__.Loops("a").As("b"))).Has("name", "vadas")).Dedup().Values("name")}},
90+
"g_V_emit": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Emit()}},
91+
"g_V_untilXidentityX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Until(gremlingo.T__.Identity())}},
92+
"g_V_timesX5X": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.V().Times(5)}},
9093
"g_unionXX": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Union()}},
9194
"g_unionXV_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Union(gremlingo.T__.V().Values("name"))}},
9295
"g_unionXVXv1X_VX4XX_name": {func(g *gremlingo.GraphTraversalSource, p map[string]interface{}) *gremlingo.GraphTraversal {return g.Union(gremlingo.T__.V(p["v1"]), gremlingo.T__.V(p["v4"])).Values("name")}},

gremlin-javascript/src/main/javascript/gremlin-javascript/test/cucumber/gremlin.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gremlin-python/src/main/python/radish/gremlin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@
8989
'g_VX1X_repeatXrepeatXunionXout_uses_out_traversesXX_whereXloops_isX0X_timesX1X_timeX2X_name': [(lambda g, vid1=None:g.V(vid1).repeat(__.repeat(__.union(__.out('uses'),__.out('traverses')).where(__.loops().is_(0))).times(1)).times(2).name)],
9090
'g_V_repeatXa_outXknows_repeatXb_outXcreatedX_filterXloops_isX0XX_emit_lang': [(lambda g:g.V().repeat('a',__.out('knows').repeat('b',__.out('created').filter_(__.loops('a').is_(0))).emit()).emit().lang)],
9191
'g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name': [(lambda g, vid6=None:g.V(vid6).repeat('a',__.both('created').simple_path()).emit(__.repeat('b',__.both('knows')).until(__.loops('b').as_('b').where(__.loops('a').as_('b'))).has('name','vadas')).dedup().name)],
92+
'g_V_emit': [(lambda g:g.V().emit())],
93+
'g_V_untilXidentityX': [(lambda g:g.V().until(__.identity()))],
94+
'g_V_timesX5X': [(lambda g:g.V().times(5))],
9295
'g_unionXX': [(lambda g:g.union())],
9396
'g_unionXV_name': [(lambda g:g.union(__.V().name))],
9497
'g_unionXVXv1X_VX4XX_name': [(lambda g, v4=None,v1=None:g.union(__.V(v1),__.V(v4)).name)],

gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/test/features/branch/Repeat.feature

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,30 @@ Feature: Step - repeat()
371371
Then the result should be unordered
372372
| result |
373373
| josh |
374+
375+
Scenario: g_V_emit
376+
Given the modern graph
377+
And the traversal of
378+
"""
379+
g.V().emit()
380+
"""
381+
When iterated to list
382+
Then the traversal will raise an error with message containing text of "The repeat()-traversal was not defined"
383+
384+
Scenario: g_V_untilXidentityX
385+
Given the modern graph
386+
And the traversal of
387+
"""
388+
g.V().until(__.identity())
389+
"""
390+
When iterated to list
391+
Then the traversal will raise an error with message containing text of "The repeat()-traversal was not defined"
392+
393+
Scenario: g_V_timesX5X
394+
Given the modern graph
395+
And the traversal of
396+
"""
397+
g.V().times(5)
398+
"""
399+
When iterated to list
400+
Then the traversal will raise an error with message containing text of "The repeat()-traversal was not defined"

0 commit comments

Comments
 (0)