tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkupp...@apache.org
Subject [tinkerpop] 01/01: TINKERPOP-2124 Fixed and/or folding in `InlineFilterStrategy`.
Date Wed, 02 Jan 2019 22:03:26 GMT
This is an automated email from the ASF dual-hosted git repository.

dkuppitz pushed a commit to branch TINKERPOP-2124
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit eb87f727341c4c8aa618f9dfbbdf4a45ea2eff25
Author: Daniel Kuppitz <daniel_kuppitz@hotmail.com>
AuthorDate: Wed Jan 2 15:01:31 2019 -0700

    TINKERPOP-2124 Fixed and/or folding in `InlineFilterStrategy`.
---
 CHANGELOG.asciidoc                                                | 1 +
 .../traversal/strategy/optimization/InlineFilterStrategy.java     | 8 ++++++--
 .../traversal/strategy/optimization/InlineFilterStrategyTest.java | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index a49a9b2..057b46d 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 This release also includes changes from <<release-3-2-11, 3.2.11>>.
 
+* Fixed and/or folding in `InlineFilterStrategy`.
 * Fixed configuration and serialization of `SubgraphStrategy` which was missing the `checkAdjacentVertices`
flag.
 * Captured `TraversalInterruptionException` and converted to `TimeoutException` for `GremlinExecutor`.
 * Fixed a bug in `CoalesceStep` which squared the bulk if the step followed a `Barrier` step.
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
index 17d1032..e2f154e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategy.java
@@ -195,6 +195,7 @@ public final class InlineFilterStrategy extends AbstractTraversalStrategy<Traver
             InlineFilterStrategy.instance().apply(childTraversal); // todo: this may be a
bad idea, but I can't seem to find a test case to break it
             for (final Step<?, ?> childStep : childTraversal.getSteps()) {
                 if (childStep instanceof HasStep) {
+                    P p = null;
                     for (final HasContainer hasContainer : ((HasStep<?>) childStep).getHasContainers())
{
                         if (null == key)
                             key = hasContainer.getKey();
@@ -202,9 +203,12 @@ public final class InlineFilterStrategy extends AbstractTraversalStrategy<Traver
                             process = false;
                             break;
                         }
-                        predicate = null == predicate ?
+                        p = null == p ?
                                 hasContainer.getPredicate() :
-                                predicate.or(hasContainer.getPredicate());
+                                p.and(hasContainer.getPredicate());
+                    }
+                    if (process) {
+                        predicate = null == predicate ? p : predicate.or(p);
                     }
                     labels.addAll(childStep.getLabels());
                 } else {
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategyTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategyTest.java
index 924182b..6fffef0 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/InlineFilterStrategyTest.java
@@ -95,6 +95,7 @@ public class InlineFilterStrategyTest {
                 {or(has("name", "marko"), filter(has("name", "bob"))), has("name", eq("marko").or(eq("bob")))},
                 {or(has("name", "marko"), filter(or(filter(has("name", "bob")), has("name",
"stephen")))), has("name", eq("marko").or(eq("bob").or(eq("stephen"))))},
                 {or(has("name", "marko").as("a"), filter(or(filter(has("name", "bob")).as("b"),
has("name", "stephen").as("c")))), has("name", eq("marko").or(eq("bob").or(eq("stephen")))).as("a",
"b", "c")},
+                {or(and(has("age",gt(20)), has("age",lt(30))), and(has("age",gt(35)), has("age",lt(40)))),
has("age", gt(20).and(lt(30)).or(gt(35).and(lt(40))))},
                 //
                 {and(has("age", gt(10)), filter(has("age", 22))), addHas(__.start(), "age",
gt(10), "age", eq(22))},
                 {and(has("age", gt(10)).as("a"), filter(has("age", 22).as("b")).as("c")).as("d"),
addHas(__.start(), "age", gt(10), "age", eq(22)).as("a", "b", "c", "d")},


Mime
View raw message