Repository: tinkerpop
Updated Branches:
  refs/heads/master 72b518609 -> fd4c93ccd


Fixed a bug in  where  should invalidate the strategy's application.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e033e3c6
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e033e3c6
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e033e3c6

Branch: refs/heads/master
Commit: e033e3c6f8132d0b461a75e479ceea8f8b4b9ca8
Parents: 12e08c3
Author: Marko A. Rodriguez <okramma...@gmail.com>
Authored: Thu Apr 13 10:54:29 2017 -0600
Committer: Marko A. Rodriguez <okramma...@gmail.com>
Committed: Thu Apr 13 10:54:29 2017 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  7 ++--
 .../optimization/RepeatUnrollStrategy.java      | 10 ++++--
 .../step/branch/GroovyRepeatTest.groovy         |  6 ++++
 .../traversal/step/branch/RepeatTest.java       | 34 ++++++++++++++++++--
 4 files changed, 50 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e033e3c6/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 18ad774..1e7be59 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,9 +26,10 @@ 
image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* Deprecated `authentication.className` setting in favor of using 
`authentication.authenticator`
-* Added `authentication.authenticationHandler` setting
-* Added abstraction to authorization to allow users to plug in their own 
`AbstractAuthorizationHandler` implementations
+* Fixed a bug in `RepeatUnrollStrategy` where `LoopsStep` should invalidate 
the strategy's application.
+* Deprecated `authentication.className` setting in favor of using 
`authentication.authenticator`.
+* Added `authentication.authenticationHandler` setting.
+* Added abstraction to authorization to allow users to plug in their own 
`AbstractAuthorizationHandler` implementations.
 * Fixed a `NullPointerException` bug in `B_LP_O_S_SE_SL_Traverser`.
 * `PathRetractionStrategy` now uses the marker-model to reduce recursive 
lookups of invalidating steps.
 * `ProfileStrategy` now uses the marker-model to reduce recursive lookups of 
`ProfileSideEffectStep`.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e033e3c6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategy.java
index 0a7cd4e..bdde1a1 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RepeatUnrollStrategy.java
@@ -20,23 +20,28 @@
 package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
 
 import org.apache.tinkerpop.gremlin.process.traversal.Scope;
+import org.apache.tinkerpop.gremlin.process.traversal.Step;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.lambda.LoopTraversal;
 import org.apache.tinkerpop.gremlin.process.traversal.step.Barrier;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.step.filter.DedupGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.LoopsStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.NoOpBarrierStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
 
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public final class RepeatUnrollStrategy extends 
AbstractTraversalStrategy<TraversalStrategy.OptimizationStrategy> implements 
TraversalStrategy.OptimizationStrategy {
 
     private static final RepeatUnrollStrategy INSTANCE = new 
RepeatUnrollStrategy();
-
     protected static final int MAX_BARRIER_SIZE = 2500;
 
     private RepeatUnrollStrategy() {
@@ -52,7 +57,8 @@ public final class RepeatUnrollStrategy extends 
AbstractTraversalStrategy<Traver
                 final RepeatStep<?> repeatStep = (RepeatStep) 
traversal.getSteps().get(i);
                 if (null == repeatStep.getEmitTraversal() &&
                         repeatStep.getUntilTraversal() instanceof 
LoopTraversal && ((LoopTraversal) repeatStep.getUntilTraversal()).getMaxLoops() 
> 0 &&
-                        
!TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, 
DedupGlobalStep.class, repeatStep.getRepeatTraversal())) {
+                        
!TraversalHelper.hasStepOfAssignableClassRecursively(Scope.global, 
DedupGlobalStep.class, repeatStep.getRepeatTraversal()) &&
+                        
!TraversalHelper.hasStepOfAssignableClassRecursively(LoopsStep.class, 
repeatStep.getRepeatTraversal())) {
                     final Traversal.Admin<?, ?> repeatTraversal = 
repeatStep.getGlobalChildren().get(0);
                     
repeatTraversal.removeStep(repeatTraversal.getSteps().size() - 1); // removes 
the RepeatEndStep
                     TraversalHelper.applySingleLevelStrategies(traversal, 
repeatTraversal, RepeatUnrollStrategy.class);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e033e3c6/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy
----------------------------------------------------------------------
diff --git 
a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy
 
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy
index c132e6c..88dce37 100644
--- 
a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy
+++ 
b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/branch/GroovyRepeatTest.groovy
@@ -84,5 +84,11 @@ public abstract class GroovyRepeatTest {
         public Traversal<Vertex, String> 
get_g_VX1X_repeatXoutX_untilXoutE_count_isX0XX_name(final Object v1Id) {
             new ScriptTraversal<>(g, "gremlin-groovy", 
"g.V(v1Id).repeat(out()).until(__.outE.count.is(0)).name", "v1Id", v1Id)
         }
+
+        @Override
+        public Traversal<Vertex, Map<Integer, Long>> 
get_g_VX1X_repeatXgroupCountXmX_byXloopsX_outX_timesX3X_capXmX(
+                final Object v1Id) {
+            new ScriptTraversal<>(g, "gremlin-groovy", 
"g.V(v1Id).repeat(groupCount('m').by(loops()).out()).times(3).cap('m')", 
"v1Id", v1Id)
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e033e3c6/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java
 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java
index db230d4..56acd2b 100644
--- 
a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java
+++ 
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/branch/RepeatTest.java
@@ -36,8 +36,17 @@ import java.util.List;
 import java.util.Map;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
-import static org.junit.Assert.*;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.groupCount;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
+import static 
org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.loops;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -70,6 +79,8 @@ public abstract class RepeatTest extends 
AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Map<String, Long>> 
get_g_V_repeatXgroupCountXmX_byXnameX_outX_timesX2X_capXmX();
 
+    public abstract Traversal<Vertex, Map<Integer, Long>> 
get_g_VX1X_repeatXgroupCountXmX_byXloopsX_outX_timesX3X_capXmX(final Object 
v1Id);
+
     //
 
     public abstract Traversal<Vertex, Map<String, Vertex>> 
get_g_V_repeatXbothX_timesX10X_asXaX_out_asXbX_selectXa_bX();
@@ -234,6 +245,20 @@ public abstract class RepeatTest extends 
AbstractGremlinProcessTest {
         checkResults(Arrays.asList("lop", "lop", "ripple", "vadas"), 
traversal);
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_VX1X_repeatXgroupCountXmX_byXloopsX_outX_capXmX() {
+        final Traversal<Vertex, Map<Integer, Long>> traversal = 
get_g_VX1X_repeatXgroupCountXmX_byXloopsX_outX_timesX3X_capXmX(convertToVertexId("marko"));
+        printTraversalForm(traversal);
+        final Map<Integer, Long> map = traversal.next();
+        assertFalse(traversal.hasNext());
+        assertEquals(3, map.size());
+        // {0=1, 1=3, 2=2}
+        assertEquals(1L, map.get(0).longValue());
+        assertEquals(3L, map.get(1).longValue());
+        assertEquals(2L, map.get(2).longValue());
+    }
+
     public static class Traversals extends RepeatTest {
 
         @Override
@@ -290,5 +315,10 @@ public abstract class RepeatTest extends 
AbstractGremlinProcessTest {
         public Traversal<Vertex, String> 
get_g_VX1X_repeatXoutX_untilXoutE_count_isX0XX_name(final Object v1Id) {
             return 
g.V(v1Id).repeat(out()).until(outE().count().is(0)).values("name");
         }
+
+        @Override
+        public Traversal<Vertex, Map<Integer, Long>> 
get_g_VX1X_repeatXgroupCountXmX_byXloopsX_outX_timesX3X_capXmX(final Object 
v1Id) {
+            return 
g.V(v1Id).repeat(groupCount("m").by(loops()).out()).times(3).cap("m");
+        }
     }
 }
\ No newline at end of file

Reply via email to