tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [01/30] tinkerpop git commit: Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals. [Forced Update!]
Date Tue, 28 Feb 2017 19:05:47 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1640 2cf41f55e -> 1a2597b88 (forced update)


Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals.


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

Branch: refs/heads/TINKERPOP-1640
Commit: fe905dda7aaf7262a2e074c2b185a4248bc7f479
Parents: 1f11dd3
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Authored: Thu Feb 23 15:33:28 2017 +0100
Committer: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
Committed: Thu Feb 23 15:33:28 2017 +0100

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../optimization/RangeByIsCountStrategy.java    | 43 ++++++++++++--------
 .../RangeByIsCountStrategyTest.java             |  9 ++--
 3 files changed, 32 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe905dda/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 871a4c9..498d227 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -31,6 +31,7 @@ TinkerPop 3.2.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 * Refactor `SparkContext` handler to support external kill and stop operations.
 * Fixed an optimization bug in `LazyBarrierStrategy` around appending barriers to the end
of a `Traversal`.
 * `TraverserIterator` in GremlinServer is smart to try and bulk traversers prior to network
I/O.
+* Fixed a bug in `RangeByIsCountStrategy` that changed the meaning of inner traversals.
 
 [[release-3-2-4]]
 TinkerPop 3.2.4 (Release Date: February 8, 2017)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/fe905dda/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 efe7685..9dcb380 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
@@ -138,25 +138,34 @@ public final class RangeByIsCountStrategy extends AbstractTraversalStrategy<Trav
                         traversal.asAdmin().removeStep(curr); // CountStep
                         size -= 2;
                         if (!dismissCountIs) {
-                            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--;
-                                }
+                            if (traversal.getParent() instanceof FilterStep) {
+                                final Step<?, ?> filterStep = parent.asStep();
+                                final Traversal.Admin parentTraversal = filterStep.getTraversal();
+                                final Step notStep = new NotStep<>(parentTraversal,
+                                        traversal.getSteps().isEmpty() ? __.identity() :
traversal);
+                                filterStep.getLabels().forEach(notStep::addLabel);
+                                TraversalHelper.replaceStep(filterStep, notStep, parentTraversal);
                             } else {
-                                inner = __.identity().asAdmin();
+                                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)
+                                    TraversalHelper.replaceStep(prev, new NotStep<>(traversal,
inner), traversal);
+                                else
+                                    traversal.asAdmin().addStep(new NotStep<>(traversal,
inner));
                             }
-                            if (prev != null)
-                                TraversalHelper.replaceStep(prev, new NotStep<>(traversal,
inner), traversal);
-                            else
-                                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/fe905dda/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 55eb840..8023e35 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
@@ -75,15 +75,16 @@ public class RangeByIsCountStrategyTest {
                 {__.map(__.count().is(0)), __.map(__.limit(1).count().is(0))},
                 {__.flatMap(__.count().is(0)), __.flatMap(__.limit(1).count().is(0))},
                 {__.flatMap(__.count().is(0)).as("a"), __.flatMap(__.count().is(0)).as("a")},
-                {__.filter(__.count().is(0)).as("a"), __.filter(__.not(__.identity())).as("a")},
-                {__.filter(__.count().is(0)), __.filter(__.not(__.identity()))},
+                {__.filter(__.count().is(0)).as("a"), __.not(__.identity()).as("a")},
+                {__.filter(__.count().is(0)), __.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")},
                 {__.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")))},
+                {__.where(__.outE().hasLabel("created").count().is(0)), __.not(__.outE().hasLabel("created"))},
+                {__.where(__.out().outE().hasLabel("created").count().is(0)), __.not(__.out().outE().hasLabel("created"))},
+                {__.where(__.out().outE().hasLabel("created").count().is(0).store("x")),
__.where(__.out().outE().hasLabel("created").limit(1).count().is(0).store("x"))},
                 {__.filter(__.bothE().count().is(gt(0))), __.filter(__.bothE())},
                 {__.filter(__.bothE().count().is(gte(1))), __.filter(__.bothE())},
                 {__.filter(__.bothE().count().is(gt(1))), __.filter(__.bothE().limit(2).count().is(gt(1)))},


Mime
View raw message