Forgot to handle `FilterSteps`.

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

Branch: refs/heads/master
Commit: 5d38bbeb591a49f5c47ed0aa7d9aece12cf3dd21
Parents: ef53888
Author: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Authored: Thu May 26 22:18:25 2016 +0200
Committer: Daniel Kuppitz <daniel_kupp...@hotmail.com>
Committed: Fri May 27 13:25:39 2016 +0200

----------------------------------------------------------------------
 .../strategy/optimization/RangeByIsCountStrategy.java     | 10 +++++-----
 .../strategy/optimization/RangeByIsCountStrategyTest.java |  1 +
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5d38bbeb/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
index 835a8f9..451d561 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategy.java
@@ -27,6 +27,7 @@ import 
org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
 import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.IsStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.NotStep;
 import 
org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
@@ -95,17 +96,16 @@ public final class RangeByIsCountStrategy extends 
AbstractTraversalStrategy<Trav
                             final Long highRangeCandidate = ((Number) 
value).longValue() + highRangeOffset;
                             final boolean update = highRange == null || 
highRangeCandidate > highRange;
                             if (update) {
-                                final boolean isNested = !(parent instanceof 
EmptyStep);
-                                if (isNested) {
+                                if (parent instanceof EmptyStep) {
+                                    useNotStep = true;
+                                } else {
                                     if (parent instanceof RepeatStep) {
                                         final RepeatStep repeatStep = 
(RepeatStep) parent;
                                         useNotStep = Objects.equals(traversal, 
repeatStep.getUntilTraversal())
                                                 || Objects.equals(traversal, 
repeatStep.getEmitTraversal());
                                     } else {
-                                        useNotStep = parent instanceof 
SideEffectStep;
+                                        useNotStep = parent instanceof 
FilterStep || parent instanceof SideEffectStep;
                                     }
-                                } else {
-                                    useNotStep = true;
                                 }
                                 highRange = highRangeCandidate;
                                 useNotStep &= curr.getLabels().isEmpty() && 
next.getLabels().isEmpty()

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5d38bbeb/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
index 8b42e7f..03d5176 100644
--- 
a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
+++ 
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/RangeByIsCountStrategyTest.java
@@ -142,6 +142,7 @@ public class RangeByIsCountStrategyTest {
                     {__.out().count().is(without(2, 6, 4)), 
__.out().limit(6).count().is(without(2, 6, 4))},
                     {__.map(__.count().is(0)), 
__.map(__.limit(1).count().is(0))},
                     {__.flatMap(__.count().is(0)), 
__.flatMap(__.limit(1).count().is(0))},
+                    {__.filter(__.count().is(0)), 
__.filter(__.not(__.identity()))},
                     {__.sideEffect(__.count().is(0)), 
__.sideEffect(__.not(__.identity()))},
                     {__.branch(__.count().is(0)), 
__.branch(__.limit(1).count().is(0))},
                     {__.count().is(0).store("x"), 
__.limit(1).count().is(0).store("x")},

Reply via email to