You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/12/07 20:02:27 UTC
[04/50] tinkerpop git commit: fixed a FilterRankStrategy bug that was
introduced with where().by(). Added test cases to verify behavior. Updated
CHANGELOG.
fixed a FilterRankStrategy bug that was introduced with where().by(). Added test cases to verify behavior. Updated CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/248ccc68
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/248ccc68
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/248ccc68
Branch: refs/heads/TINKERPOP-1490
Commit: 248ccc685720535e93b1b2ac3adc94443e697c68
Parents: 0d4ee56
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Nov 15 12:10:22 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Nov 16 05:44:18 2016 -0700
----------------------------------------------------------------------
CHANGELOG.asciidoc | 5 +++++
.../optimization/FilterRankingStrategy.java | 12 +++++++-----
.../optimization/FilterRankingStrategyTest.java | 3 +++
.../traversal/step/filter/GroovyWhereTest.groovy | 5 +++++
.../process/traversal/step/filter/WhereTest.java | 16 ++++++++++++++++
5 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/248ccc68/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 7c4d41f..0613a39 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -27,6 +27,11 @@ TinkerPop 3.2.4 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Converted Spark process suite tests to "integration" tests.
+* Fixed a bug in `InlineFilterStrategy` having to do with folding `HasContainers` into `VertexStep`.
+* Deprecated `HasContainer.makeHasContainers()` which was used to dissect `AndP` and shouldn't be used at the TinkerPop-level.
+* `GraphTraversal.has()` now will try and fold-left `HasContainer` if end step is a `HasContainerHolder`.
+* Created explicit `P`-predicate methods for `GraphTraversal.hasXXX()`.
+* Fixed a bug in `FilterRankStrategy` around `where().by()` ordering.
* Added another optimization in `RangeByIsCountStrategy`, that removes `count().is()` altogether if it's not needed.
* Fixed a OLAP `MatchStep.clone()`-bug that occurs when the `match()` is in a local child.
* Added another optimization in `RangeByIsCountStrategy`, that removes `count().is()` altogether if it's not needed.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/248ccc68/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java
index 2f8061b..4ff485a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategy.java
@@ -126,7 +126,7 @@ public final class FilterRankingStrategy extends AbstractTraversalStrategy<Trave
return 1;
else if (step instanceof HasStep)
return 2;
- else if (step instanceof WherePredicateStep)
+ else if (step instanceof WherePredicateStep && ((WherePredicateStep) step).getLocalChildren().isEmpty())
return 3;
else if (step instanceof SimplePathStep || step instanceof CyclicPathStep)
return 4;
@@ -134,14 +134,16 @@ public final class FilterRankingStrategy extends AbstractTraversalStrategy<Trave
return 5;
else if (step instanceof WhereTraversalStep)
return 6;
- else if (step instanceof OrStep)
+ else if (step instanceof WherePredicateStep) // has by()-modulation
return 7;
- else if (step instanceof AndStep)
+ else if (step instanceof OrStep)
return 8;
- else if (step instanceof DedupGlobalStep)
+ else if (step instanceof AndStep)
return 9;
- else if (step instanceof OrderGlobalStep)
+ else if (step instanceof DedupGlobalStep)
return 10;
+ else if (step instanceof OrderGlobalStep)
+ return 11;
else
return 0;
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/248ccc68/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategyTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategyTest.java
index fbeeef5..577e160 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategyTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/FilterRankingStrategyTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
@@ -105,6 +106,8 @@ public class FilterRankingStrategyTest {
{__.dedup().has("value", 0).or(not(has("age")), has("age", 10)).has("value", 1), __.has("value", 0).has("value", 1).or(not(has("age")), has("age", 10)).dedup(), Collections.singletonList(InlineFilterStrategy.instance())},
{__.dedup().filter(out()).has("value", 0), has("value", 0).filter(out()).dedup(), Collections.emptyList()},
{filter(out()).dedup().has("value", 0), has("value", 0).filter(out()).dedup(), Collections.emptyList()},
+ {__.as("a").out().has("age").where(P.eq("a")), __.as("a").out().where(P.eq("a")).has("age"), Collections.emptyList()},
+ {__.as("a").out().has("age").where(P.eq("a")).by("age"), __.as("a").out().has("age").where(P.eq("a")).by("age"), Collections.emptyList()},
{has("value", 0).filter(out()).dedup(), has("value", 0).filter(out()).dedup(), Collections.emptyList()},
{has("value", 0).or(has("name"), has("age")).has("value", 1).dedup(), has("value", 0).has("value", 1).or(has("name"), has("age")).dedup(), Collections.singletonList(InlineFilterStrategy.instance())},
{has("value", 0).or(out(), in()).as(Graph.Hidden.hide("x")).has("value", 1).dedup(), has("value", 0).has("value", 1).or(outE(), inE()).dedup(), TraversalStrategies.GlobalCache.getStrategies(Graph.class).toList()},
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/248ccc68/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy
index 9348524..02bf5ef 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/filter/GroovyWhereTest.groovy
@@ -152,5 +152,10 @@ public abstract class GroovyWhereTest {
new ScriptTraversal<>(g, "gremlin-groovy", "g.V().as('a').outE('created').as('b').inV().as('c').in('created').as('d').where('a', lt('b').or(gt('c')).and(neq('d'))).by('age').by('weight').by(__.in('created').values('age').min()).select('a', 'c', 'd').by('name')")
}
+ @Override
+ public Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name(final Object v1Id) {
+ new ScriptTraversal<>(g, "gremlin-groovy", "g.V(v1Id).as('a').out.has('age').where(gt('a')).by('age').name", "v1Id", v1Id)
+ }
+
}
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/248ccc68/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
index ef2a5e4..c9a25ad 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/WhereTest.java
@@ -119,6 +119,8 @@ public abstract class WhereTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Map<String, String>> get_g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX();
+ public abstract Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name(final Object v1Id);
+
@Test
@LoadGraphWith(MODERN)
public void g_V_hasXageX_asXaX_out_in_hasXageX_asXbX_selectXa_bX_whereXa_eqXbXX() {
@@ -385,6 +387,15 @@ public abstract class WhereTest extends AbstractGremlinProcessTest {
"a", "josh", "c", "lop", "d", "peter"), traversal);
}
+ @Test
+ @LoadGraphWith(MODERN)
+ public void g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name() {
+ final Traversal<Vertex, String> traversal = get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name(convertToVertexId(graph, "marko"));
+ printTraversalForm(traversal);
+ assertEquals("josh", traversal.next());
+ assertFalse(traversal.hasNext());
+ }
+
public static class Traversals extends WhereTest {
@@ -504,5 +515,10 @@ public abstract class WhereTest extends AbstractGremlinProcessTest {
public Traversal<Vertex, Map<String, String>> get_g_V_asXaX_outEXcreatedX_asXbX_inV_asXcX_inXcreatedX_asXdX_whereXa_ltXbX_orXgtXcXX_andXneqXdXXX_byXageX_byXweightX_byXinXcreatedX_valuesXageX_minX_selectXa_c_dX() {
return g.V().as("a").outE("created").as("b").inV().as("c").in("created").as("d").where("a", lt("b").or(gt("c")).and(neq("d"))).by("age").by("weight").by(in("created").values("age").min()).<String>select("a", "c", "d").by("name");
}
+
+ @Override
+ public Traversal<Vertex, String> get_g_VX1X_asXaX_out_hasXageX_whereXgtXaXX_byXageX_name(final Object v1Id) {
+ return g.V(v1Id).as("a").out().has("age").where(gt("a")).by("age").values("name");
+ }
}
}
\ No newline at end of file