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/16 17:52:28 UTC

incubator-tinkerpop git commit: Started benchmarking XMatchStep vs. MatchStep --- nearly identical.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 19f5c2cc7 -> 6d88eb649


Started benchmarking XMatchStep vs. MatchStep --- nearly identical.


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

Branch: refs/heads/master
Commit: 6d88eb6494d26fe5c94a1c9db49c3b9a05f0d080
Parents: 19f5c2c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Jun 16 09:52:14 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Jun 16 09:52:22 2015 -0600

----------------------------------------------------------------------
 .../traversal/step/filter/exp/XMatchStep.java   |  4 +-
 .../tinkergraph/structure/TinkerGraphTest.java  | 53 +++++++++++++++++---
 2 files changed, 47 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6d88eb64/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
index 04a0972..31c1a52 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
@@ -410,7 +410,7 @@ public final class XMatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
         public Traversal.Admin<Object, Object> apply(final Traverser.Admin<Object> traverser) {
             final Path path = traverser.path();
             for (int i = 0; i < this.traversals.size(); i++) {
-                if (!this.requiredLabels.get(i).stream().filter(label -> !path.hasLabel(label)).findAny().isPresent() && !path.hasLabel(this.traversalLabels.get(i))) {
+                if (!path.hasLabel(this.traversalLabels.get(i)) && !this.requiredLabels.get(i).stream().filter(label -> !path.hasLabel(label)).findAny().isPresent()) {
                     return this.traversals.get(i);
                 }
             }
@@ -440,7 +440,7 @@ public final class XMatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
         public Traversal.Admin<Object, Object> apply(final Traverser.Admin<Object> traverser) {
             final Path path = traverser.path();
             for (final Integer[] indexCounts : this.counts) {
-                if (!this.requiredLabels.get(indexCounts[0]).stream().filter(label -> !path.hasLabel(label)).findAny().isPresent() && !path.hasLabel(this.traversalLabels.get(indexCounts[0]))) {
+                if (!path.hasLabel(this.traversalLabels.get(indexCounts[0])) && !this.requiredLabels.get(indexCounts[0]).stream().filter(label -> !path.hasLabel(label)).findAny().isPresent()) {
                     return this.traversals.get(indexCounts[0]);
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6d88eb64/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 3589644..4931f34 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
@@ -20,7 +20,6 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.tinkerpop.gremlin.process.traversal.Operator;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.process.traversal.Pop;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
 import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -157,8 +156,46 @@ public class TinkerGraphTest {
 
     @Test
     @Ignore
+    public void testPlay7() throws Exception {
+        Graph graph = TinkerGraph.open();
+        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
+        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
+        //System.out.println(g.E().label().groupCount().next());
+        final Supplier<Traversal<?, ?>> traversal = () ->
+                /*g.V().match("a",
+                        as("a").in("sungBy").as("b"),
+                        as("a").in("writtenBy").as("b")).select().by("name");*/
+                /*g.V().xmatch("a",
+                        as("a").out("followedBy").as("b"),
+                        as("b").out("followedBy").as("a")).select().by("name");*/
+                /*g.V().xmatch("a",
+                        as("a").in("followedBy").as("b"),
+                        as("a").out("sungBy").as("c"),
+                        as("a").out("writtenBy").as("d")).select().by("name");*/
+                /*g.V().match("a",
+                        as("a").in("followedBy").as("b"),
+                        as("a").out("sungBy").as("c"),
+                        as("a").out("writtenBy").as("d")).
+                        where("c", P.neq("d")).select().by("name");*/
+                /*g.V().xmatch("a",
+                        as("a").in("sungBy").as("b"),
+                        as("a").in("writtenBy").as("b"),
+                        as("b").out("followedBy").as("c"),
+                        as("c").out("sungBy").as("a"),
+                        as("c").out("writtenBy").as("a")).select().by("name");*/
+                g.V().xmatch("a",
+                        as("a").has("name","Garcia"),
+                        as("a").in("writtenBy").as("b"),
+                        as("b").out("followedBy").as("c"),
+                        as("c").out("writtenBy").has("name",P.neq("Garcia")).as("d")).select().by("name");
+
+        System.out.println(TimeUtil.clockWithResult(100, () -> traversal.get().toList().size()));
+    }
+
+    @Test
+    @Ignore
     public void testPlay5() throws Exception {
-        GraphTraversalSource g = TinkerFactory.createModern().traversal(GraphTraversalSource.standard());
+        GraphTraversalSource g = TinkerFactory.createModern().traversal(GraphTraversalSource.computer());
         /*final Supplier<Traversal<?, ?>> traversal = () -> g.V().xmatch("a",
                 as("a").out("created").as("b"),
                 or(
@@ -184,7 +221,7 @@ public class TinkerGraphTest {
                         ),
                         as("b").in("created").as("c"),
                         as("b").where(in("created").count().is(P.gt(1))))
-                .select().by("name");
+                        .select();
 
         System.out.println(traversal.get());
         System.out.println(traversal.get().iterate());
@@ -199,18 +236,18 @@ public class TinkerGraphTest {
     public void testPlay6() throws Exception {
         final Graph graph = TinkerGraph.open();
         final GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
-        for(int i=0; i<1000; i++) {
-            graph.addVertex(T.label, "person",T.id,i);
+        for (int i = 0; i < 1000; i++) {
+            graph.addVertex(T.label, "person", T.id, i);
         }
         graph.vertices().forEachRemaining(a -> {
             graph.vertices().forEachRemaining(b -> {
-                if(a != b) {
-                   a.addEdge("knows",b);
+                if (a != b) {
+                    a.addEdge("knows", b);
                 }
             });
         });
         graph.vertices(50).next().addEdge("uncle", graph.vertices(70).next());
-        System.out.println(TimeUtil.clockWithResult(100,() -> g.V().xmatch("a",as("a").out("knows").as("b"),as("a").out("uncle").as("b")).toList()));
+        System.out.println(TimeUtil.clockWithResult(1, () -> g.V().xmatch("a", as("a").out("knows").as("b"), as("a").out("uncle").as("b")).toList()));
     }
 
     @Test