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 2016/03/31 22:53:13 UTC
[05/11] incubator-tinkerpop git commit: added an insano, nested,
sideEffect-ridden group-based traversal w/ multi-cap to ensure
property OLTP and OLAP evaluation. Bingo.
added an insano, nested, sideEffect-ridden group-based traversal w/ multi-cap to ensure property OLTP and OLAP evaluation. Bingo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/53ee3ee6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/53ee3ee6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/53ee3ee6
Branch: refs/heads/master
Commit: 53ee3ee63b0c2dc47b0949f2bfd8109a32229b73
Parents: 71b1d37
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu Mar 31 07:57:11 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu Mar 31 07:57:11 2016 -0600
----------------------------------------------------------------------
.../step/sideEffect/GroovyGroupTest.groovy | 5 +++
.../traversal/step/sideEffect/GroupTest.java | 47 ++++++++++++++++++++
2 files changed, 52 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/53ee3ee6/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
index 65ca078..619815f 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroovyGroupTest.groovy
@@ -103,5 +103,10 @@ public abstract class GroovyGroupTest {
public Traversal<Vertex, Map<String, Map<String, Long>>> get_g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX() {
new ScriptTraversal<>(g, "gremlin-groovy", "g.V.hasLabel('song').group('a').by('name').by(__.properties().groupCount.by(label)).out.cap('a')")
}
+
+ @Override
+ public Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() {
+ new ScriptTraversal<>(g, "gremlin-groovy", "g.V.repeat(union(out('knows').group('a').by('age'), out('created').group('b').by('name').by(count())).group('a').by('name')).times(2).cap('a', 'b')")
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/53ee3ee6/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
index 400ee33..d844ba7 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/GroupTest.java
@@ -31,6 +31,7 @@ import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import static org.apache.tinkerpop.gremlin.LoadGraphWith.GraphData.GRATEFUL;
@@ -81,6 +82,8 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
public abstract Traversal<Vertex, Map<String, Map<String, Long>>> get_g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX();
+ public abstract Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX();
+
@Test
@LoadGraphWith(MODERN)
public void g_V_group_byXnameX() {
@@ -313,6 +316,45 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
assertFalse(traversal.hasNext());
}
+ @Test
+ @LoadGraphWith(MODERN)
+ public void g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() {
+ //[{a={32=[v[4]], ripple=[v[5], v[5]], vadas=[v[2]], 27=[v[2]], josh=[v[4]], lop=[v[3], v[3], v[3], v[3]]}, b={ripple=2, lop=4}}]
+ final Traversal<Vertex, Map<String, Map<Object, Object>>> traversal = get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX();
+ printTraversalForm(traversal);
+ assertTrue(traversal.hasNext());
+ final Map<String, Map<Object, Object>> map = traversal.next();
+ assertFalse(traversal.hasNext());
+ assertEquals(2, map.size());
+ assertTrue(map.containsKey("a"));
+ assertTrue(map.containsKey("b"));
+ //
+ final Map<Object, List<Vertex>> mapA = (Map) map.get("a");
+ assertEquals(6, mapA.size());
+ assertEquals(1, mapA.get(32).size());
+ assertEquals(convertToVertex(graph, "josh"), mapA.get(32).get(0));
+ assertEquals(1, mapA.get(27).size());
+ assertEquals(convertToVertex(graph, "vadas"), mapA.get(27).get(0));
+ assertEquals(2, mapA.get("ripple").size());
+ assertEquals(convertToVertex(graph, "ripple"), mapA.get("ripple").get(0));
+ assertEquals(convertToVertex(graph, "ripple"), mapA.get("ripple").get(1));
+ assertEquals(1, mapA.get("vadas").size());
+ assertEquals(convertToVertex(graph, "vadas"), mapA.get("vadas").get(0));
+ assertEquals(1, mapA.get("josh").size());
+ assertEquals(convertToVertex(graph, "josh"), mapA.get("josh").get(0));
+ assertEquals(4, mapA.get("lop").size());
+ assertEquals(convertToVertex(graph, "lop"), mapA.get("lop").get(0));
+ assertEquals(convertToVertex(graph, "lop"), mapA.get("lop").get(1));
+ assertEquals(convertToVertex(graph, "lop"), mapA.get("lop").get(2));
+ assertEquals(convertToVertex(graph, "lop"), mapA.get("lop").get(3));
+ //
+ final Map<String, Long> mapB = (Map) map.get("b");
+ assertEquals(2, mapB.size());
+ assertEquals(2l, mapB.get("ripple").longValue());
+ assertEquals(4l, mapB.get("lop").longValue());
+ //
+ checkSideEffects(traversal.asAdmin().getSideEffects(), "a", HashMap.class, "b", HashMap.class);
+ }
public static class Traversals extends GroupTest {
@@ -390,5 +432,10 @@ public abstract class GroupTest extends AbstractGremlinProcessTest {
public Traversal<Vertex, Map<String, Map<String, Long>>> get_g_V_hasLabelXsongX_groupXaX_byXnameX_byXproperties_groupCount_byXlabelXX_out_capXaX() {
return g.V().hasLabel("song").group("a").by("name").by(__.properties().groupCount().by(T.label)).out().cap("a");
}
+
+ @Override
+ public Traversal<Vertex, Map<String, Map<Object, Object>>> get_g_V_repeatXunionXoutXknowsX_groupXaX_byXageX__outXcreatedX_groupXbX_byXnameX_byXcountXX_groupXaX_byXnameXX_timesX2X_capXa_bX() {
+ return g.V().repeat(__.union(__.out("knows").group("a").by("age"), __.out("created").group("b").by("name").by(count())).group("a").by("name")).times(2).cap("a", "b");
+ }
}
}