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/11/10 15:04:40 UTC

incubator-tinkerpop git commit: added a barrier()-based test that fails in OLAP, but passes in OLTP. I originally thought the solution was a simple 'step instanceof Barrier' check, but its actually more complex than that. It involves using GraphComputer.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP3-951 [created] 978047776


added a barrier()-based test that fails in OLAP, but passes in OLTP. I originally thought the solution was a simple 'step instanceof Barrier' check, but its actually more complex than that. It involves using GraphComputer.Memory and a 'latch' mechanism to ensure that all processing up to that step has occurred. Thus, a distributed lock for barriers. I think the solution will be easy, just not a 'dead simple' fix for 3.1.0...Will save for 3.1.1.


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

Branch: refs/heads/TINKERPOP3-951
Commit: 9780477769ed1eafb089b70e258694eb69bb496f
Parents: b9e7c42
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Tue Nov 10 07:04:50 2015 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Tue Nov 10 07:04:50 2015 -0700

----------------------------------------------------------------------
 .../step/sideEffect/GroovySackTest.groovy       |  8 ++++++-
 .../traversal/step/sideEffect/SackTest.java     | 23 ++++++++++++++++----
 2 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97804777/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
index 2eab85d..4d67b22 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovySackTest.groovy
@@ -62,12 +62,18 @@ public abstract class GroovySackTest {
         @Override
         public Traversal<Vertex, Double> get_g_withSackX1_sumX_VX1X_localXoutXknowsX_barrierXnormSackXX_inXknowsX_barrier_sack(
                 final Object v1Id) {
-            TraversalScriptHelper.compute("g.withSack(1.0d,sum).V(${v1Id}).local(out('knows').barrier(normSack)).in('knows').barrier.sack", g, "v1Id", v1Id)
+            TraversalScriptHelper.compute("g.withSack(1.0d,sum).V(v1Id).local(out('knows').barrier(normSack)).in('knows').barrier.sack", g, "v1Id", v1Id)
         }
 
         @Override
         public Traversal<Vertex, Integer> get_g_withBulkXfalseX_withSackX1_sumX_V_out_barrier_sack() {
             TraversalScriptHelper.compute("g.withBulk(false).withSack(1, sum).V.out.barrier.sack", g);
         }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_withBulkXfalseX_withSackX1_sumX_VX1X_unionXoutXknowsX_outXcreatedX_sackXmultX_byXconstantX1XX__outXcreatedXX_barrier_whereXsack_isXneqX0XXX(
+                final Object v1Id) {
+            TraversalScriptHelper.compute("g.withBulk(false).withSack(1,sum).V(v1Id).union(out('knows').out('created').sack(mult).by(constant(-1)), out('created')).barrier.where(sack().is(neq(0)))", g, "v1Id", v1Id);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/97804777/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackTest.java
index c88ea19..4cbd7fe 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SackTest.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.LoadGraphWith;
 import org.apache.tinkerpop.gremlin.process.AbstractGremlinProcessTest;
 import org.apache.tinkerpop.gremlin.process.GremlinProcessRunner;
 import org.apache.tinkerpop.gremlin.process.traversal.Operator;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.process.traversal.SackFunctions;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -31,14 +32,13 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.MODERN;
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
+import static org.junit.Assert.*;
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
@@ -64,6 +64,8 @@ public abstract class SackTest extends AbstractGremlinProcessTest {
 
     public abstract Traversal<Vertex, Integer> get_g_withBulkXfalseX_withSackX1_sumX_V_out_barrier_sack();
 
+    public abstract Traversal<Vertex, Vertex> get_g_withBulkXfalseX_withSackX1_sumX_VX1X_unionXoutXknowsX_outXcreatedX_sackXmultX_byXconstantX1XX__outXcreatedXX_barrier_whereXsack_isXneqX0XXX(final Object v1Id);
+
     @Test
     @LoadGraphWith(MODERN)
     public void g_withSackXhellowX_V_outE_sackXassignX_byXlabelX_inV_sack() {
@@ -139,6 +141,14 @@ public abstract class SackTest extends AbstractGremlinProcessTest {
         checkResults(Arrays.asList(1, 1, 1, 3), traversal); // josh, vadas, ripple, lop
     }
 
+    @Test
+    @LoadGraphWith(MODERN)
+    public void g_withBulkXfalseX_withSackX1_sumX_VX1X_unionXoutXknowsX_outXcreatedX_sackXmultX_byXconstantX1XX__outXcreatedXX_barrier_whereXsack_isXneqX0XXX() {
+        final Traversal<Vertex, Vertex> traversal = get_g_withBulkXfalseX_withSackX1_sumX_VX1X_unionXoutXknowsX_outXcreatedX_sackXmultX_byXconstantX1XX__outXcreatedXX_barrier_whereXsack_isXneqX0XXX(convertToVertexId(graph, "marko"));
+        printTraversalForm(traversal);
+        checkResults(Collections.singletonList(convertToVertex(graph, "ripple")), traversal);
+    }
+
     public static class Traversals extends SackTest {
 
         @Override
@@ -183,5 +193,10 @@ public abstract class SackTest extends AbstractGremlinProcessTest {
         public Traversal<Vertex, Integer> get_g_withBulkXfalseX_withSackX1_sumX_V_out_barrier_sack() {
             return g.withBulk(false).withSack(1, Operator.sum).V().out().barrier().sack();
         }
+
+        @Override
+        public Traversal<Vertex, Vertex> get_g_withBulkXfalseX_withSackX1_sumX_VX1X_unionXoutXknowsX_outXcreatedX_sackXmultX_byXconstantX1XX__outXcreatedXX_barrier_whereXsack_isXneqX0XXX(final Object v1Id) {
+            return g.withBulk(false).withSack(1, Operator.sum).V(v1Id).union(out("knows").out("created").sack(Operator.mult).by(constant(-1)), out("created")).barrier().where(sack().is(P.neq(0)));
+        }
     }
 }
\ No newline at end of file