tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject tinkerpop git commit: Enclose filter steps and side-effect steps in `RangeByIsCountStrategy` when `NotStep` is used to wrap part of the traversal.
Date Mon, 12 Sep 2016 17:28:21 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1391-master [created] d1d4a6285


Enclose filter steps and side-effect steps in `RangeByIsCountStrategy` when `NotStep` is used
to wrap part of the traversal.


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

Branch: refs/heads/TINKERPOP-1391-master
Commit: d1d4a6285d163e28e8298f3d07ea8824980ef8f7
Parents: 4222630
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Mon Sep 12 19:21:19 2016 +0200
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Mon Sep 12 19:27:34 2016 +0200

----------------------------------------------------------------------
 .../optimization/RangeByIsCountStrategy.java    | 20 +++++++++++++++++---
 .../RangeByIsCountStrategyTest.java             |  2 ++
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d1d4a628/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 451d561..6957abe 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
@@ -32,6 +32,7 @@ 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;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountGlobalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.SideEffectStep;
 import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
 import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
@@ -130,12 +131,25 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                             traversal.asAdmin().removeStep(next); // IsStep
                             traversal.asAdmin().removeStep(curr); // CountStep
                             size -= 2;
+                            final Traversal.Admin inner;
+                            if (prev != null) {
+                                inner = __.start().asAdmin();
+                                for (; ; ) {
+                                    final Step pp = prev.getPreviousStep();
+                                    inner.addStep(0, prev);
+                                    if (pp instanceof EmptyStep || pp instanceof GraphStep
||
+                                            !(prev instanceof FilterStep || prev instanceof
SideEffectStep)) break;
+                                    traversal.removeStep(prev);
+                                    prev = pp;
+                                    size--;
+                                }
+                            } else {
+                                inner = __.identity().asAdmin();
+                            }
                             if (prev != null) {
-                                final Traversal.Admin inner = __.start().asAdmin();
-                                TraversalHelper.insertAfterStep(prev, inner.getStartStep(),
inner);
                                 TraversalHelper.replaceStep(prev, new NotStep<>(traversal,
inner), traversal);
                             } else {
-                                traversal.asAdmin().addStep(new NotStep<>(traversal,
__.identity()));
+                                traversal.asAdmin().addStep(new NotStep<>(traversal,
inner));
                             }
                         } else {
                             TraversalHelper.insertBeforeStep(new RangeGlobalStep<>(traversal,
0L, highRange), curr, traversal);

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d1d4a628/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 0e9539d..99d2f75 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
@@ -93,6 +93,8 @@ public class RangeByIsCountStrategyTest {
                 {__.count().is(0).store("x"), __.limit(1).count().is(0).store("x")},
                 {__.repeat(__.out()).until(__.outE().count().is(0)), __.repeat(__.out()).until(__.not(__.outE()))},
                 {__.repeat(__.out()).emit(__.outE().count().is(0)), __.repeat(__.out()).emit(__.not(__.outE()))},
+                {__.where(__.outE().hasLabel("created").count().is(0)), __.where(__.not(__.outE().hasLabel("created")))},
+                {__.where(__.out().outE().hasLabel("created").count().is(0)), __.where(__.out().not(__.outE().hasLabel("created")))},
         });
     }
 }


Mime
View raw message