[
https://issues.apache.org/jira/browse/TINKERPOP3-949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Marko A. Rodriguez closed TINKERPOP3-949.
-----------------------------------------
Resolution: Won't Fix
Closing this as this is not a problem. If I am wrong, please reopen with an
argument.
> times(x) after RepeatStep violates do while semantics.
> ------------------------------------------------------
>
> Key: TINKERPOP3-949
> URL: https://issues.apache.org/jira/browse/TINKERPOP3-949
> Project: TinkerPop 3
> Issue Type: Bug
> Components: process
> Affects Versions: 3.0.2-incubating
> Reporter: pieter martin
> Assignee: Daniel Kuppitz
>
> {noformat}
> @Test
> public void testTimesAfterRepeat() {
> final TinkerGraph g = TinkerGraph.open();
> Vertex a1 = g.addVertex(T.label, "A", "name", "a1");
> Vertex b1 = g.addVertex(T.label, "B", "name", "b1");
> Vertex c1 = g.addVertex(T.label, "C", "name", "c1");
> Vertex d1 = g.addVertex(T.label, "D", "name", "d1");
> a1.addEdge("ab", b1);
> b1.addEdge("bc", c1);
> c1.addEdge("cd", d1);
> List<Vertex> vertices =
> g.traversal().V().hasLabel("A").emit().repeat(__.out()).times(2).toList();
> assertEquals(4, vertices.size());
> }
> {noformat}
> This test will fail for as it will return only 3 vertices.
> The current implementation of RepeatStep implements {{while do}} semantics
> for a {{LoopTraversal}} regardless of the position of the {{times}} clause in
> the gremlin query.
> a1->b1->c1->d1
> start at a1, emit a1
> travers to b1 loop==0
> emit b1 travers c1 loop==1
> emit c1 traverse d1 loop==2
> d1 is the last element so it is returned.
> a1, b1, c1 emitted and d1 is the last.
> Ultimately if I understand the intended semantics correctly,
> {{repeat().times(a)}} is equivalent to {{times(a + 1).repeat()}}
> Having a look at {{RepeatStep.standardAlgorithm}} I see that the loop counter
> is always incremented before {{doUntil}}. This translates to {{while do}}
> semantics. For {{do while}} semantics the increment should occur after the
> {{doUntil}}
> Or the {{LoopTraversal}} should be smarter about its predicate for {{do
> while}}
> I am testing on the 3.0.2-incubating branch. I have only been working on
> repeatSteps that start from a GraphStep. The same applies to starting from a
> VertexStep but I am not yet there.
> With my current understanding of {{LoopTraversal}} and {{do while}} semantics
> the following tests are failling,
> {{RepeatTest.g_V_repeatXoutX_timesX2X}}
> {{RepeatTest.g_V_repeatXoutX_timesX2X_repeatXinX_timesX2X_name}}
> {{PathTest.g_V_repeatXoutX_timesX2X_path_byXitX_byXnameX_byXlangX}}
> {{GroupTest.g_V_repeatXbothXfollowedByXX_timesX2X_group_byXsongTypeX_byXcountX}}
> {{GroupTest.g_V_repeatXbothXfollowedByXX_timesX2X_groupXaX_byXsongTypeX_byXcountX_capXaX}}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)