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 Thu, 10 Jan 2019 14:51:09 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit d0424217f3ce9e04d9ef2c4a5db9b83b8a132f28
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                                                | 2 ++
 .../traversal/strategy/optimization/InlineFilterStrategy.java     | 8 ++++++--
 .../traversal/strategy/optimization/InlineFilterStrategyTest.java | 1 +
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 52af532..1c88119 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -278,12 +278,14 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 * Masked sensitive configuration options in the logs of `KryoShimServiceLoader`.
 * Fixed a concurrency issue in `TraverserSet`
+* Fixed a bug in `InlineFilterStrategy` that mixed up and's and or's when folding merging
conditions together.
 
 [[release-3-3-5]]
 === TinkerPop 3.3.5 (Release Date: January 2, 2019)
 
 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 512f6e5..cf54f50 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
@@ -107,6 +107,7 @@ public class InlineFilterStrategyTest {
                 {or(has("name", "marko"), filter(has("name", "bob"))), has("name", eq("marko").or(eq("bob"))),
Collections.emptyList()},
                 {or(has("name", "marko"), filter(or(filter(has("name", "bob")), has("name",
"stephen")))), has("name", eq("marko").or(eq("bob").or(eq("stephen")))), Collections.emptyList()},
                 {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"), Collections.emptyList()},
+                {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)))), Collections.emptyList()},
                 //
                 {has("name", "marko").and().has("name", "marko").and().has("name", "marko"),
has("name", "marko").has("name", "marko").has("name", "marko"), Collections.emptyList()},
                 {filter(has("name", "marko")).and().filter(has("name", "marko")).and().filter(has("name",
"marko")), has("name", "marko").has("name", "marko").has("name", "marko"), Collections.emptyList()},


Mime
View raw message