You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/06/18 19:51:02 UTC

incubator-tinkerpop git commit: added the test cases the pulls out the HasContainer for index lookups in MatchStep.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master e469fabc2 -> 2ced06c66


added the test cases the pulls out the HasContainer for index lookups in MatchStep.


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

Branch: refs/heads/master
Commit: 2ced06c66b5e20f90502c6f21c8c765fd6fdcec9
Parents: e469fab
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Jun 18 11:50:47 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Jun 18 11:50:57 2015 -0600

----------------------------------------------------------------------
 .../traversal/step/map/GroovyMatchTest.groovy   | 33 ++++++++++-------
 .../process/traversal/step/map/MatchTest.java   | 25 ++++++++++++-
 .../tinkergraph/structure/TinkerGraphTest.java  | 39 +++++++-------------
 3 files changed, 57 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2ced06c6/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
index 4477226..09cc6e8 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/map/GroovyMatchTest.groovy
@@ -18,17 +18,10 @@
  */
 package org.apache.tinkerpop.gremlin.process.traversal.step.map
 
-import org.apache.tinkerpop.gremlin.process.traversal.P
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalScriptHelper
-import org.apache.tinkerpop.gremlin.structure.T
 import org.apache.tinkerpop.gremlin.structure.Vertex
 
-import static org.apache.tinkerpop.gremlin.process.traversal.P.neq
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.or
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.where;
-
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
@@ -188,7 +181,7 @@ public abstract class GroovyMatchTest {
                     __.as("b").in("created").has("age", 29).as("c"))
                     .where(__.as("c").repeat(__.out).times(2))
                     .select.by('name')
-            """,g)
+            """, g)
         }
 
         @Override
@@ -199,7 +192,7 @@ public abstract class GroovyMatchTest {
                     __.as('b').in('created').as('c'))
                     .where('a', neq('c'))
                     .select('a', 'c').by('name')
-            """,g)
+            """, g)
         }
 
         @Override
@@ -208,7 +201,7 @@ public abstract class GroovyMatchTest {
                 g.V.match('a',
                     __.as('a').out('created').as('b'),
                     __.as('c').out('created').as('b')).select().by('name')
-            """,g)
+            """, g)
         }
 
         @Override
@@ -217,7 +210,7 @@ public abstract class GroovyMatchTest {
                 g.V.out.out.match('a',
                     __.as('b').out('created').as('a'),
                     __.as('c').out('knows').as('b')).select('c').out('knows').name
-            """,g)
+            """, g)
         }
 
         @Override
@@ -233,14 +226,26 @@ public abstract class GroovyMatchTest {
                     __.as('b').in('created').as('c'),
                     __.as('b').in('created').count.is(gt(1)))
                     .select.by(id);
-            """,g)
+            """, g)
         }
 
         @Override
-        public Traversal<Vertex,Map<String,Object>> get_g_V_asXaX_out_asXbX_matchXa_out_count_c__b_in_count_cX() {
+        public Traversal<Vertex, Map<String, Object>> get_g_V_asXaX_out_asXbX_matchXa_out_count_c__b_in_count_cX() {
             TraversalScriptHelper.compute("""
                 g.V.as('a').out.as('b').match(__.as('a').out.count.as('c'), __.as('b').in.count.as('c'))
-            """,g)
+            """, g)
+        }
+
+        @Override
+        public Traversal<Vertex, Map<String, Vertex>> get_g_V_matchXa__a_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX() {
+            TraversalScriptHelper.compute("""
+                g.V.match('a',
+                    __.as('a').has('name', 'Garcia'),
+                    __.as('a').in('writtenBy').as('b'),
+                    __.as('b').out('followedBy').as('c'),
+                    __.as('c').out('writtenBy').as('d'),
+                    where('d', neq('a')))
+            """, g)
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2ced06c6/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
index 36087fe..40dfb6b 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/MatchTest.java
@@ -107,6 +107,9 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
     // uses local barrier count() and no start key
     public abstract Traversal<Vertex,Map<String,Object>> get_g_V_asXaX_out_asXbX_matchXa_out_count_c__b_in_count_cX();
 
+    // pulls out has container for index lookup and uses an where() with startKey and predicate
+    public abstract Traversal<Vertex,Map<String,Vertex>> get_g_V_matchXa__a_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX();
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_V_matchXa_out_bX() throws Exception {
@@ -332,7 +335,7 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
                 "a", convertToVertexId("marko"), "b", convertToVertexId("lop"), "c", convertToVertexId("josh"),
                 "a", convertToVertexId("marko"), "b", convertToVertexId("lop"), "c", convertToVertexId("peter"),
                 "a", convertToVertexId("josh"), "b", convertToVertexId("lop"), "c", convertToVertexId("marko"),
-                "a", convertToVertexId("josh"), "b", convertToVertexId("lop"), "c", convertToVertexId("peter")),traversal);
+                "a", convertToVertexId("josh"), "b", convertToVertexId("lop"), "c", convertToVertexId("peter")), traversal);
     }
 
     @Test
@@ -343,6 +346,17 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
         checkResults(makeMapList(3, "a",convertToVertex(graph,"marko"),"c",3l,"b",convertToVertex(graph,"lop")),traversal);
     }
 
+    @Test
+    @LoadGraphWith(GRATEFUL)
+    public void g_V_matchXa__a_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX() {
+        final Traversal<Vertex,Map<String,Vertex>> traversal= get_g_V_matchXa__a_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX();
+        printTraversalForm(traversal);
+        checkResults(makeMapList(4,
+                "a", convertToVertex(graph, "Garcia"), "b", convertToVertex(graph,"CRYPTICAL ENVELOPMENT"), "c", convertToVertex(graph,"WHARF RAT"), "d", convertToVertex(graph,"Hunter"),
+                "a", convertToVertex(graph, "Garcia"), "b", convertToVertex(graph,"CRYPTICAL ENVELOPMENT"), "c", convertToVertex(graph,"THE OTHER ONE"), "d", convertToVertex(graph,"Weir"),
+                "a", convertToVertex(graph, "Garcia"), "b", convertToVertex(graph,"CRYPTICAL ENVELOPMENT"), "c", convertToVertex(graph,"DRUMS"), "d", convertToVertex(graph,"Grateful_Dead")), traversal);
+    }
+
     public static class Traversals extends MatchTest {
         @Override
         public Traversal<Vertex, Map<String, Vertex>> get_g_V_matchXa_out_bX() {
@@ -511,5 +525,14 @@ public abstract class MatchTest extends AbstractGremlinProcessTest {
             return g.V().as("a").out().as("b").match(as("a").out().count().as("c"), as("b").in().count().as("c"));
         }
 
+        @Override
+        public Traversal<Vertex,Map<String,Vertex>> get_g_V_matchXa__a_hasXname_GarciaX__a_0writtenBy_b__b_followedBy_c__c_writtenBy_d__whereXd_neqXaXXX() {
+            return g.V().match("a",
+                    as("a").has("name", "Garcia"),
+                    as("a").in("writtenBy").as("b"),
+                    as("b").out("followedBy").as("c"),
+                    as("c").out("writtenBy").as("d"),
+                    where("d", P.neq("a")));
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/2ced06c6/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 1916379..b57a836 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -221,48 +221,37 @@ public class TinkerGraphTest {
     @Test
     @Ignore
     public void testPlay5() throws Exception {
-        GraphTraversalSource g = TinkerFactory.createModern().traversal(GraphTraversalSource.computer());
-        /*final Supplier<Traversal<?, ?>> traversal = () -> g.V().xmatch("a",
-                as("a").out("created").as("b"),
-                or(
-                        as("a").out("knows").as("c"),
-                        or(
-                                as("a").out("created").has("name", "ripple"),
-                                as("a").out().out()
-                        )
-                )).select().by("name");*/
 
-        /*final Supplier<Traversal<?, ?>> traversal = () -> g.V().
-                xmatch("a",
-                as("a").local(out("created").count()).as("b"))
-                .select().by("name");*/
+        TinkerGraph graph = TinkerGraph.open();
+        graph.createIndex("name",Vertex.class);
+        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
+        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
 
-        final Supplier<Traversal<?, ?>> traversal = () ->
+        /*final Supplier<Traversal<?, ?>> traversal = () ->
                 g.V().match("a",
                         where("a", P.neq("c")),
                         as("a").out("created").as("b"),
                         or(
                                 as("a").out("knows").has("name", "vadas"),
-                                as("a").in("knows").and().as("a").has(T.label,"person")
+                                as("a").in("knows").and().as("a").has(T.label, "person")
                         ),
                         as("b").in("created").as("c"),
                         as("b").in("created").count().is(P.gt(1)))
-                        .select().by("name");
+                        .select(); */
 
-        /*final Supplier<Traversal<?,?>> traversal = () ->
-                g.V().xmatch("a",
-                        as("a").out("knows").count().as("b"),
-                        as("a").out("knows").as("c"),
-                        as("c").out("created").count().as("b")).select("a","b","c").by("name").by().by("name");*/
+        final Supplier<Traversal<?,?>> traversal = () ->
+                g.V().match("a",
+                        as("a").has("name", "Garcia"),
+                        as("a").in("writtenBy").as("b"),
+                        as("b").out("followedBy").as("c"),
+                        as("c").out("writtenBy").as("d"),
+                        as("d").where(P.neq("a"))).select().by("name");
 
        /*final Supplier<Traversal<?,?>> traversal = () ->
                 g.V().as("a").out().as("b").where(
                         not(in("knows").as("a")).and().as("b").in().count().is(P.gt(1))
                 ).select().by("name"); */
 
-        /*final Supplier<Traversal<?,?>> traversal = () ->
-                g.V().as("a").out("created").as("b").in("created").as("c").both("knows").both("knows").as("d").where("c",P.not(P.eq("a").or(P.eq("d")))).select().by("name"); */
-
         System.out.println(traversal.get());
         System.out.println(traversal.get().iterate());
         traversal.get().forEachRemaining(System.out::println);