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 2015/09/30 16:46:17 UTC

[1/5] incubator-tinkerpop git commit: Minor javadoc fixes.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/tp30 9f2973490 -> 78cfe5b12


Minor javadoc fixes.


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

Branch: refs/heads/tp30
Commit: 6686935a6086ded86f6bd65e89bf0274923b3c04
Parents: 9f29734
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 07:50:16 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 07:50:16 2015 -0400

----------------------------------------------------------------------
 .../java/org/apache/tinkerpop/gremlin/structure/Graph.java  | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6686935a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index 14b987f..0d8710f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -281,7 +281,7 @@ public interface Graph extends AutoCloseable, Host {
 
     /**
      * Get the {@link org.apache.commons.configuration.Configuration} associated with the construction of this graph.
-     * Whatever configuration was passed to {@link org.apache.tinkerpop.gremlin.structure.util.GraphFactory#open(org.apache.commons.configuration.Configuration)}
+     * Whatever configuration was passed to {@link GraphFactory#open(org.apache.commons.configuration.Configuration)}
      * is what should be returned by this method.
      *
      * @return the configuration used during graph construction.
@@ -289,7 +289,7 @@ public interface Graph extends AutoCloseable, Host {
     public Configuration configuration();
 
     /**
-     * Graph variables are a set of key/value pairs associated with the graph.The keys are String and the values
+     * Graph variables are a set of key/value pairs associated with the graph. The keys are String and the values
      * are Objects.
      */
     public interface Variables {
@@ -400,8 +400,7 @@ public interface Graph extends AutoCloseable, Host {
             public static final String FEATURE_CONCURRENT_ACCESS = "ConcurrentAccess";
 
             /**
-             * Determines if the {@code Graph} implementation supports
-             * {@link org.apache.tinkerpop.gremlin.process.computer.GraphComputer} based processing.
+             * Determines if the {@code Graph} implementation supports {@link GraphComputer} based processing.
              */
             @FeatureDescriptor(name = FEATURE_COMPUTER)
             public default boolean supportsComputer() {
@@ -441,7 +440,7 @@ public interface Graph extends AutoCloseable, Host {
 
             /**
              * Determines if the {@code Graph} implementation supports threaded transactions which allow a transaction
-             * to be executed across multiple threads via {@link org.apache.tinkerpop.gremlin.structure.Transaction#createThreadedTx()}.
+             * to be executed across multiple threads via {@link Transaction#createThreadedTx()}.
              */
             @FeatureDescriptor(name = FEATURE_THREADED_TRANSACTIONS)
             public default boolean supportsThreadedTransactions() {


[5/5] incubator-tinkerpop git commit: Add apache header.

Posted by sp...@apache.org.
Add apache header.


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

Branch: refs/heads/tp30
Commit: 78cfe5b12dafd7c5d049b9ecf4972c65caebc931
Parents: 550509f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 10:44:13 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 10:44:13 2015 -0400

----------------------------------------------------------------------
 .../structure/TinkerGraphPlayTest.java            | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/78cfe5b1/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
index a7b64d9..97ccffd 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -1,3 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
 import org.apache.tinkerpop.gremlin.process.traversal.Operator;


[3/5] incubator-tinkerpop git commit: Move all the tinkergraph play tests to their own class.

Posted by sp...@apache.org.
Move all the tinkergraph play tests to their own class.


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

Branch: refs/heads/tp30
Commit: fb6d006b03162789eb2ae698310a34489d40fa19
Parents: 5aa2886
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 09:37:46 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 09:37:46 2015 -0400

----------------------------------------------------------------------
 .../structure/TinkerGraphPlayTest.java          | 218 +++++++++++++++++++
 .../tinkergraph/structure/TinkerGraphTest.java  | 203 -----------------
 2 files changed, 218 insertions(+), 203 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fb6d006b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
new file mode 100644
index 0000000..a7b64d9
--- /dev/null
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphPlayTest.java
@@ -0,0 +1,218 @@
+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.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
+import org.apache.tinkerpop.gremlin.util.TimeUtil;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.function.Supplier;
+
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.and;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.as;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.both;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.choose;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.has;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.in;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.out;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.outE;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.select;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.union;
+import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.valueMap;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class TinkerGraphPlayTest {
+
+    @Test
+    @Ignore
+    public void testPlay() {
+        Graph g = TinkerGraph.open();
+        Vertex v1 = g.addVertex(T.id, "1", "animal", "males");
+        Vertex v2 = g.addVertex(T.id, "2", "animal", "puppy");
+        Vertex v3 = g.addVertex(T.id, "3", "animal", "mama");
+        Vertex v4 = g.addVertex(T.id, "4", "animal", "puppy");
+        Vertex v5 = g.addVertex(T.id, "5", "animal", "chelsea");
+        Vertex v6 = g.addVertex(T.id, "6", "animal", "low");
+        Vertex v7 = g.addVertex(T.id, "7", "animal", "mama");
+        Vertex v8 = g.addVertex(T.id, "8", "animal", "puppy");
+        Vertex v9 = g.addVertex(T.id, "9", "animal", "chula");
+
+        v1.addEdge("link", v2, "weight", 2f);
+        v2.addEdge("link", v3, "weight", 3f);
+        v2.addEdge("link", v4, "weight", 4f);
+        v2.addEdge("link", v5, "weight", 5f);
+        v3.addEdge("link", v6, "weight", 1f);
+        v4.addEdge("link", v6, "weight", 2f);
+        v5.addEdge("link", v6, "weight", 3f);
+        v6.addEdge("link", v7, "weight", 2f);
+        v6.addEdge("link", v8, "weight", 3f);
+        v7.addEdge("link", v9, "weight", 1f);
+        v8.addEdge("link", v9, "weight", 7f);
+
+        g.traversal().withSack(Float.MIN_VALUE).V(v1).repeat(outE().sack(Operator.max, "weight").inV()).times(5).sack().forEachRemaining(System.out::println);
+    }
+
+   /* @Test
+    public void testTraversalDSL() throws Exception {
+        Graph g = TinkerFactory.createClassic();
+        assertEquals(2, g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().toList().size());
+        g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().forEachRemaining(name -> assertTrue(name.equals("josh") || name.equals("vadas")));
+        assertEquals(1, g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().toList().size());
+        g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().forEachRemaining(name -> assertEquals("lop", name));
+    }*/
+
+    @Test
+    @Ignore
+    public void benchmarkStandardTraversals() throws Exception {
+        Graph graph = TinkerGraph.open();
+        GraphTraversalSource g = graph.traversal();
+        graph.io(GraphMLIo.build()).readGraph("data/grateful-dead.xml");
+        final List<Supplier<Traversal>> traversals = Arrays.asList(
+                () -> g.V().outE().inV().outE().inV().outE().inV(),
+                () -> g.V().out().out().out(),
+                () -> g.V().out().out().out().path(),
+                () -> g.V().repeat(out()).times(2),
+                () -> g.V().repeat(out()).times(3),
+                () -> g.V().local(out().out().values("name").fold()),
+                () -> g.V().out().local(out().out().values("name").fold()),
+                () -> g.V().out().map(v -> g.V(v.get()).out().out().values("name").toList())
+        );
+        traversals.forEach(traversal -> {
+            System.out.println("\nTESTING: " + traversal.get());
+            for (int i = 0; i < 7; i++) {
+                final long t = System.currentTimeMillis();
+                traversal.get().iterate();
+                System.out.print("   " + (System.currentTimeMillis() - t));
+            }
+        });
+    }
+
+    @Test
+    @Ignore
+    public void testPlay4() throws Exception {
+        Graph graph = TinkerGraph.open();
+        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
+        GraphTraversalSource g = graph.traversal();
+        final List<Supplier<Traversal>> traversals = Arrays.asList(
+                () -> g.V().has(T.label, "song").out().groupCount().<Vertex>by(t ->
+                        g.V(t).choose(r -> g.V(r).has(T.label, "artist").hasNext(),
+                                in("writtenBy", "sungBy"),
+                                both("followedBy")).values("name").next()).fold(),
+                () -> g.V().has(T.label, "song").out().groupCount().<Vertex>by(t ->
+                        g.V(t).choose(has(T.label, "artist"),
+                                in("writtenBy", "sungBy"),
+                                both("followedBy")).values("name").next()).fold(),
+                () -> g.V().has(T.label, "song").out().groupCount().by(
+                        choose(has(T.label, "artist"),
+                                in("writtenBy", "sungBy"),
+                                both("followedBy")).values("name")).fold(),
+                () -> g.V().has(T.label, "song").both().groupCount().<Vertex>by(t -> g.V(t).both().values("name").next()),
+                () -> g.V().has(T.label, "song").both().groupCount().by(both().values("name")));
+        traversals.forEach(traversal -> {
+            System.out.println("\nTESTING: " + traversal.get());
+            for (int i = 0; i < 10; i++) {
+                final long t = System.currentTimeMillis();
+                traversal.get().iterate();
+                //System.out.println(traversal.get().toList());
+                System.out.print("   " + (System.currentTimeMillis() - t));
+            }
+        });
+    }
+
+    @Test
+    @Ignore
+    public void testPlayDK() throws Exception {
+        final Graph graph = TinkerFactory.createModern();
+        final GraphTraversalSource g = graph.traversal();
+        Traversal traversal = g.V().where(out().and().in()).profile().cap(TraversalMetrics.METRICS_KEY);
+        //traversal.forEachRemaining(System.out::println);
+        System.out.println(traversal.toString());
+        traversal.asAdmin().applyStrategies();
+        System.out.println(traversal.toString());
+        traversal.forEachRemaining(System.out::println);
+        traversal = g.V().where(and(out(), in())).profile().cap(TraversalMetrics.METRICS_KEY);
+        //traversal.forEachRemaining(System.out::println);
+        System.out.println(traversal.toString());
+        traversal.asAdmin().applyStrategies();
+        System.out.println(traversal.toString());
+        //System.out.println(traversal.toString());
+    }
+
+    @Test
+    @Ignore
+    public void testPlay7() throws Exception {
+        /*TinkerGraph graph = TinkerGraph.open();
+        graph.createIndex("name",Vertex.class);
+        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");*/
+        //System.out.println(g.V().properties().key().groupCount().next());
+        TinkerGraph graph = TinkerFactory.createModern();
+        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
+        final List<Supplier<GraphTraversal<?,?>>> traversals = Arrays.asList(
+                () -> g.V().out().as("v").match(
+                        __.as("v").outE().count().as("outDegree"),
+                        __.as("v").inE().count().as("inDegree")).select("v","outDegree","inDegree").by(valueMap()).by().by().local(union(select("v"), select("inDegree", "outDegree")).unfold().fold())
+        );
+
+        traversals.forEach(traversal -> {
+            System.out.println("pre-strategy:  " + traversal.get());
+            System.out.println("post-strategy: " + traversal.get().iterate());
+            System.out.println(TimeUtil.clockWithResult(50, () -> traversal.get().toList()));
+        });
+    }
+
+    @Test
+    @Ignore
+    public void testPlay5() throws Exception {
+
+        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 = () ->
+                g.V().match(
+                        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("a","b","c","d").by("name");
+
+
+        System.out.println(traversal.get());
+        System.out.println(traversal.get().iterate());
+        traversal.get().forEachRemaining(System.out::println);
+
+    }
+
+    @Test
+    @Ignore
+    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);
+        }
+        graph.vertices().forEachRemaining(a -> {
+            graph.vertices().forEachRemaining(b -> {
+                if (a != b) {
+                    a.addEdge("knows", b);
+                }
+            });
+        });
+        graph.vertices(50).next().addEdge("uncle", graph.vertices(70).next());
+        System.out.println(TimeUtil.clockWithResult(500, () -> g.V().match(as("a").out("knows").as("b"), as("a").out("uncle").as("b")).toList()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/fb6d006b/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 6b23710..3d763b7 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
@@ -18,30 +18,13 @@
  */
 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.Scope;
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
 import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.T;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.structure.io.graphml.GraphMLIo;
-import org.apache.tinkerpop.gremlin.util.TimeUtil;
-import org.junit.Ignore;
 import org.junit.Test;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
-import java.util.function.Supplier;
 
-import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -52,186 +35,6 @@ import static org.junit.Assert.assertTrue;
 public class TinkerGraphTest {
 
     @Test
-    @Ignore
-    public void testPlay() {
-        Graph g = TinkerGraph.open();
-        Vertex v1 = g.addVertex(T.id, "1", "animal", "males");
-        Vertex v2 = g.addVertex(T.id, "2", "animal", "puppy");
-        Vertex v3 = g.addVertex(T.id, "3", "animal", "mama");
-        Vertex v4 = g.addVertex(T.id, "4", "animal", "puppy");
-        Vertex v5 = g.addVertex(T.id, "5", "animal", "chelsea");
-        Vertex v6 = g.addVertex(T.id, "6", "animal", "low");
-        Vertex v7 = g.addVertex(T.id, "7", "animal", "mama");
-        Vertex v8 = g.addVertex(T.id, "8", "animal", "puppy");
-        Vertex v9 = g.addVertex(T.id, "9", "animal", "chula");
-
-        v1.addEdge("link", v2, "weight", 2f);
-        v2.addEdge("link", v3, "weight", 3f);
-        v2.addEdge("link", v4, "weight", 4f);
-        v2.addEdge("link", v5, "weight", 5f);
-        v3.addEdge("link", v6, "weight", 1f);
-        v4.addEdge("link", v6, "weight", 2f);
-        v5.addEdge("link", v6, "weight", 3f);
-        v6.addEdge("link", v7, "weight", 2f);
-        v6.addEdge("link", v8, "weight", 3f);
-        v7.addEdge("link", v9, "weight", 1f);
-        v8.addEdge("link", v9, "weight", 7f);
-
-        g.traversal().withSack(Float.MIN_VALUE).V(v1).repeat(outE().sack(Operator.max, "weight").inV()).times(5).sack().forEachRemaining(System.out::println);
-    }
-
-   /* @Test
-    public void testTraversalDSL() throws Exception {
-        Graph g = TinkerFactory.createClassic();
-        assertEquals(2, g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().toList().size());
-        g.of(TinkerFactory.SocialTraversal.class).people("marko").knows().name().forEachRemaining(name -> assertTrue(name.equals("josh") || name.equals("vadas")));
-        assertEquals(1, g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().toList().size());
-        g.of(TinkerFactory.SocialTraversal.class).people("marko").created().name().forEachRemaining(name -> assertEquals("lop", name));
-    }*/
-
-    @Test
-    @Ignore
-    public void benchmarkStandardTraversals() throws Exception {
-        Graph graph = TinkerGraph.open();
-        GraphTraversalSource g = graph.traversal();
-        graph.io(GraphMLIo.build()).readGraph("data/grateful-dead.xml");
-        final List<Supplier<Traversal>> traversals = Arrays.asList(
-                () -> g.V().outE().inV().outE().inV().outE().inV(),
-                () -> g.V().out().out().out(),
-                () -> g.V().out().out().out().path(),
-                () -> g.V().repeat(out()).times(2),
-                () -> g.V().repeat(out()).times(3),
-                () -> g.V().local(out().out().values("name").fold()),
-                () -> g.V().out().local(out().out().values("name").fold()),
-                () -> g.V().out().map(v -> g.V(v.get()).out().out().values("name").toList())
-        );
-        traversals.forEach(traversal -> {
-            System.out.println("\nTESTING: " + traversal.get());
-            for (int i = 0; i < 7; i++) {
-                final long t = System.currentTimeMillis();
-                traversal.get().iterate();
-                System.out.print("   " + (System.currentTimeMillis() - t));
-            }
-        });
-    }
-
-    @Test
-    @Ignore
-    public void testPlay4() throws Exception {
-        Graph graph = TinkerGraph.open();
-        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");
-        GraphTraversalSource g = graph.traversal();
-        final List<Supplier<Traversal>> traversals = Arrays.asList(
-                () -> g.V().has(T.label, "song").out().groupCount().<Vertex>by(t ->
-                        g.V(t).choose(r -> g.V(r).has(T.label, "artist").hasNext(),
-                                in("writtenBy", "sungBy"),
-                                both("followedBy")).values("name").next()).fold(),
-                () -> g.V().has(T.label, "song").out().groupCount().<Vertex>by(t ->
-                        g.V(t).choose(has(T.label, "artist"),
-                                in("writtenBy", "sungBy"),
-                                both("followedBy")).values("name").next()).fold(),
-                () -> g.V().has(T.label, "song").out().groupCount().by(
-                        choose(has(T.label, "artist"),
-                                in("writtenBy", "sungBy"),
-                                both("followedBy")).values("name")).fold(),
-                () -> g.V().has(T.label, "song").both().groupCount().<Vertex>by(t -> g.V(t).both().values("name").next()),
-                () -> g.V().has(T.label, "song").both().groupCount().by(both().values("name")));
-        traversals.forEach(traversal -> {
-            System.out.println("\nTESTING: " + traversal.get());
-            for (int i = 0; i < 10; i++) {
-                final long t = System.currentTimeMillis();
-                traversal.get().iterate();
-                //System.out.println(traversal.get().toList());
-                System.out.print("   " + (System.currentTimeMillis() - t));
-            }
-        });
-    }
-
-    @Test
-    @Ignore
-    public void testPlayDK() throws Exception {
-        final Graph graph = TinkerFactory.createModern();
-        final GraphTraversalSource g = graph.traversal();
-        Traversal traversal = g.V().where(out().and().in()).profile().cap(TraversalMetrics.METRICS_KEY);
-        //traversal.forEachRemaining(System.out::println);
-        System.out.println(traversal.toString());
-        traversal.asAdmin().applyStrategies();
-        System.out.println(traversal.toString());
-        traversal.forEachRemaining(System.out::println);
-        traversal = g.V().where(and(out(), in())).profile().cap(TraversalMetrics.METRICS_KEY);
-        //traversal.forEachRemaining(System.out::println);
-        System.out.println(traversal.toString());
-        traversal.asAdmin().applyStrategies();
-        System.out.println(traversal.toString());
-        //System.out.println(traversal.toString());
-    }
-
-    @Test
-    @Ignore
-    public void testPlay7() throws Exception {
-        /*TinkerGraph graph = TinkerGraph.open();
-        graph.createIndex("name",Vertex.class);
-        graph.io(GraphMLIo.build()).readGraph("/Users/marko/software/tinkerpop/tinkerpop3/data/grateful-dead.xml");*/
-        //System.out.println(g.V().properties().key().groupCount().next());
-        TinkerGraph graph = TinkerFactory.createModern();
-        GraphTraversalSource g = graph.traversal(GraphTraversalSource.standard());
-        final List<Supplier<GraphTraversal<?,?>>> traversals = Arrays.asList(
-                () -> g.V().out().as("v").match(
-                        __.as("v").outE().count().as("outDegree"),
-                        __.as("v").inE().count().as("inDegree")).select("v","outDegree","inDegree").by(valueMap()).by().by().local(union(select("v"), select("inDegree", "outDegree")).unfold().fold())
-        );
-
-        traversals.forEach(traversal -> {
-            System.out.println("pre-strategy:  " + traversal.get());
-            System.out.println("post-strategy: " + traversal.get().iterate());
-            System.out.println(TimeUtil.clockWithResult(50, () -> traversal.get().toList()));
-        });
-    }
-
-    @Test
-    @Ignore
-    public void testPlay5() throws Exception {
-
-        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 = () ->
-                g.V().match(
-                        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("a","b","c","d").by("name");
-
-
-        System.out.println(traversal.get());
-        System.out.println(traversal.get().iterate());
-        traversal.get().forEachRemaining(System.out::println);
-
-    }
-
-    @Test
-    @Ignore
-    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);
-        }
-        graph.vertices().forEachRemaining(a -> {
-            graph.vertices().forEachRemaining(b -> {
-                if (a != b) {
-                    a.addEdge("knows", b);
-                }
-            });
-        });
-        graph.vertices(50).next().addEdge("uncle", graph.vertices(70).next());
-        System.out.println(TimeUtil.clockWithResult(500, () -> g.V().match(as("a").out("knows").as("b"), as("a").out("uncle").as("b")).toList()));
-    }
-
-    @Test
     public void shouldManageIndices() {
         final TinkerGraph g = TinkerGraph.open();
 
@@ -306,7 +109,6 @@ public class TinkerGraphTest {
         g.createIndex("", Edge.class);
     }
 
-    @Ignore
     @Test
     public void shouldUpdateVertexIndicesInNewGraph() {
         final TinkerGraph g = TinkerGraph.open();
@@ -326,7 +128,6 @@ public class TinkerGraphTest {
         }, 35)).has("name", "stephen").count().next());
     }
 
-    @Ignore
     @Test
     public void shouldRemoveAVertexFromAnIndex() {
         final TinkerGraph g = TinkerGraph.open();
@@ -353,7 +154,6 @@ public class TinkerGraphTest {
         }, 35)).has("name", "stephen").count().next());
     }
 
-    @Ignore
     @Test
     public void shouldUpdateVertexIndicesInExistingGraph() {
         final TinkerGraph g = TinkerGraph.open();
@@ -381,7 +181,6 @@ public class TinkerGraphTest {
         }, 35)).has("name", "stephen").count().next());
     }
 
-    @Ignore
     @Test
     public void shouldUpdateEdgeIndicesInNewGraph() {
         final TinkerGraph g = TinkerGraph.open();
@@ -402,7 +201,6 @@ public class TinkerGraphTest {
         }, 0.5)).has("oid", "1").count().next());
     }
 
-    @Ignore
     @Test
     public void shouldRemoveEdgeFromAnIndex() {
         final TinkerGraph g = TinkerGraph.open();
@@ -430,7 +228,6 @@ public class TinkerGraphTest {
         }, 0.5)).has("oid", "1").count().next());
     }
 
-    @Ignore
     @Test
     public void shouldUpdateEdgeIndicesInExistingGraph() {
         final TinkerGraph g = TinkerGraph.open();


[4/5] incubator-tinkerpop git commit: Add tests to validate all IO options work for TinkerGraph persistence.

Posted by sp...@apache.org.
Add tests to validate all IO options work for TinkerGraph persistence.


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

Branch: refs/heads/tp30
Commit: 550509fc742be9bed8911a992a4034df61afe7a6
Parents: fb6d006
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 09:47:38 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 09:47:38 2015 -0400

----------------------------------------------------------------------
 .../tinkergraph/structure/TinkerGraphTest.java  | 71 ++++++++++++++++++++
 1 file changed, 71 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/550509fc/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 3d763b7..627cd0f 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
@@ -18,11 +18,16 @@
  */
 package org.apache.tinkerpop.gremlin.tinkergraph.structure;
 
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.P;
 import org.apache.tinkerpop.gremlin.structure.Edge;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.junit.Test;
 
+import java.io.File;
 import java.util.Set;
 
 import static org.junit.Assert.assertEquals;
@@ -256,5 +261,71 @@ public class TinkerGraphTest {
         }, 0.5)).has("oid", "1").count().next());
     }
 
+    @Test(expected = IllegalStateException.class)
+    public void shouldRequireGraphLocationIfFormatIsSet() {
+        final Configuration conf = new BaseConfiguration();
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphml");
+        TinkerGraph.open(conf);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void shouldRequireGraphFormatIfLocationIsSet() {
+        final Configuration conf = new BaseConfiguration();
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, "/tmp");
+        TinkerGraph.open(conf);
+    }
+
+    @Test
+    public void shouldPersistToGraphML() {
+        final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGraphML.xml";
+        final File f = new File(graphLocation);
+        if (f.exists() && f.isFile()) f.delete();
+
+        final Configuration conf = new BaseConfiguration();
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphml");
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+        final TinkerGraph graph = TinkerGraph.open(conf);
+        TinkerFactory.generateModern(graph);
+        graph.close();
+
+        final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+        IoTest.assertModernGraph(reloadedGraph, true, true);
+        reloadedGraph.close();
+    }
 
+    @Test
+    public void shouldPersistToGraphSON() {
+        final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGraphSON.json";
+        final File f = new File(graphLocation);
+        if (f.exists() && f.isFile()) f.delete();
+
+        final Configuration conf = new BaseConfiguration();
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphson");
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+        final TinkerGraph graph = TinkerGraph.open(conf);
+        TinkerFactory.generateModern(graph);
+        graph.close();
+
+        final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+        IoTest.assertModernGraph(reloadedGraph, true, false);
+        reloadedGraph.close();
+    }
+
+    @Test
+    public void shouldPersistToGryo() {
+        final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGryo.kryo";
+        final File f = new File(graphLocation);
+        if (f.exists() && f.isFile()) f.delete();
+
+        final Configuration conf = new BaseConfiguration();
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "gryo");
+        conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+        final TinkerGraph graph = TinkerGraph.open(conf);
+        TinkerFactory.generateModern(graph);
+        graph.close();
+
+        final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+        IoTest.assertModernGraph(reloadedGraph, true, false);
+        reloadedGraph.close();
+    }
 }


[2/5] incubator-tinkerpop git commit: Get basic persistence into TinkerGraph via configuration.

Posted by sp...@apache.org.
Get basic persistence into TinkerGraph via configuration.


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

Branch: refs/heads/tp30
Commit: 5aa2886a957bddde377560dbe35be0d6d441922a
Parents: 6686935
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 09:31:04 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 09:31:04 2015 -0400

----------------------------------------------------------------------
 .../tinkergraph/structure/TinkerGraph.java      | 76 ++++++++++++++++----
 .../tinkergraph/TinkerGraphProvider.java        | 22 +++++-
 2 files changed, 82 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5aa2886a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
index 54be94d..af64e3a 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java
@@ -28,6 +28,8 @@ import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.Transaction;
 import org.apache.tinkerpop.gremlin.structure.Vertex;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoMapper;
 import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
 import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
 import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
@@ -36,6 +38,8 @@ import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComp
 import org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.optimization.TinkerGraphStepStrategy;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
+import java.io.File;
+import java.io.IOException;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
@@ -77,6 +81,8 @@ public final class TinkerGraph implements Graph {
     public static final String CONFIG_EDGE_ID = "gremlin.tinkergraph.edgeIdManager";
     public static final String CONFIG_VERTEX_PROPERTY_ID = "gremlin.tinkergraph.vertexPropertyIdManager";
     public static final String CONFIG_DEFAULT_VERTEX_PROPERTY_CARDINALITY = "gremlin.tinkergraph.defaultVertexPropertyCardinality";
+    public static final String CONFIG_GRAPH_LOCATION = "gremlin.tinkergraph.graphLocation";
+    public static final String CONFIG_GRAPH_FORMAT = "gremlin.tinkergraph.graphFormat";
 
     private final TinkerGraphFeatures features = new TinkerGraphFeatures();
 
@@ -95,17 +101,28 @@ public final class TinkerGraph implements Graph {
     protected final VertexProperty.Cardinality defaultVertexPropertyCardinality;
 
     private final Configuration configuration;
+    private final String graphLocation;
+    private final String graphFormat;
 
     /**
      * An empty private constructor that initializes {@link TinkerGraph}.
      */
     private TinkerGraph(final Configuration configuration) {
         this.configuration = configuration;
-        this.vertexIdManager = selectIdManager(configuration, CONFIG_VERTEX_ID, Vertex.class);
-        this.edgeIdManager = selectIdManager(configuration, CONFIG_EDGE_ID, Edge.class);
-        this.vertexPropertyIdManager = selectIdManager(configuration, CONFIG_VERTEX_PROPERTY_ID, VertexProperty.class);
-        this.defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf(
+        vertexIdManager = selectIdManager(configuration, CONFIG_VERTEX_ID, Vertex.class);
+        edgeIdManager = selectIdManager(configuration, CONFIG_EDGE_ID, Edge.class);
+        vertexPropertyIdManager = selectIdManager(configuration, CONFIG_VERTEX_PROPERTY_ID, VertexProperty.class);
+        defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf(
                 configuration.getString(CONFIG_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.single.name()));
+
+        graphLocation = configuration.getString(CONFIG_GRAPH_LOCATION, null);
+        graphFormat = configuration.getString(CONFIG_GRAPH_FORMAT, null);
+
+        if ((graphLocation != null && null == graphFormat) || (null == graphLocation && graphFormat != null))
+            throw new IllegalStateException(String.format("The %s and %s must both be specified if either is present",
+                    CONFIG_GRAPH_LOCATION, CONFIG_GRAPH_FORMAT));
+
+        if (graphLocation != null) loadGraph();
     }
 
     /**
@@ -195,6 +212,7 @@ public final class TinkerGraph implements Graph {
 
     @Override
     public void close() {
+        if (graphLocation != null) saveGraph();
     }
 
     @Override
@@ -217,6 +235,40 @@ public final class TinkerGraph implements Graph {
         return createElementIterator(Edge.class, edges, edgeIdManager, edgeIds);
     }
 
+    private void loadGraph() {
+        final File f = new File(graphLocation);
+        if (f.exists() && f.isFile()) {
+            try {
+                if (graphFormat.equals("graphml")) {
+                    io(IoCore.graphml()).readGraph(graphLocation);
+                } else if (graphFormat.equals("graphson")) {
+                    io(IoCore.graphson()).readGraph(graphLocation);
+                } else if (graphFormat.equals("gryo")) {
+                    io(IoCore.gryo()).readGraph(graphLocation);
+                }
+            } catch (IOException ioe) {
+                throw new RuntimeException(String.format("Could not load graph at %s with %s", graphLocation, graphFormat));
+            }
+        }
+    }
+
+    private void saveGraph() {
+        final File f = new File(graphLocation);
+        if (f.exists()) f.delete();
+
+        try {
+            if (graphFormat.equals("graphml")) {
+                io(IoCore.graphml()).writeGraph(graphLocation);
+            } else if (graphFormat.equals("graphson")) {
+                io(IoCore.graphson()).writeGraph(graphLocation);
+            } else if (graphFormat.equals("gryo")) {
+                io(IoCore.gryo()).writeGraph(graphLocation);
+            }
+        } catch (IOException ioe) {
+            throw new RuntimeException(String.format("Could not save graph at %s with %s", graphLocation, graphFormat));
+        }
+    }
+
     private <T extends Element> Iterator<T> createElementIterator(final Class<T> clazz, final Map<Object, T> elements,
                                                                   final IdManager idManager,
                                                                   final Object... ids) {
@@ -267,9 +319,9 @@ public final class TinkerGraph implements Graph {
     public class TinkerGraphFeatures implements Features {
 
         private final TinkerGraphGraphFeatures graphFeatures = new TinkerGraphGraphFeatures();
+
         private final TinkerGraphEdgeFeatures edgeFeatures = new TinkerGraphEdgeFeatures();
         private final TinkerGraphVertexFeatures vertexFeatures = new TinkerGraphVertexFeatures();
-
         private TinkerGraphFeatures() {
         }
 
@@ -292,11 +344,11 @@ public final class TinkerGraph implements Graph {
         public String toString() {
             return StringFactory.featureString(this);
         }
-    }
 
+    }
     public class TinkerGraphVertexFeatures implements Features.VertexFeatures {
-        private final TinkerGraphVertexPropertyFeatures vertexPropertyFeatures = new TinkerGraphVertexPropertyFeatures();
 
+        private final TinkerGraphVertexPropertyFeatures vertexPropertyFeatures = new TinkerGraphVertexPropertyFeatures();
         private TinkerGraphVertexFeatures() {
         }
 
@@ -317,11 +369,10 @@ public final class TinkerGraph implements Graph {
 
         @Override
         public VertexProperty.Cardinality getCardinality(final String key) {
-            //return VertexProperty.Cardinality.single;
             return defaultVertexPropertyCardinality;
         }
-    }
 
+    }
     public class TinkerGraphEdgeFeatures implements Features.EdgeFeatures {
 
         private TinkerGraphEdgeFeatures() {
@@ -336,8 +387,8 @@ public final class TinkerGraph implements Graph {
         public boolean willAllowId(final Object id) {
             return edgeIdManager.allow(id);
         }
-    }
 
+    }
     public class TinkerGraphGraphFeatures implements Features.GraphFeatures {
 
         private TinkerGraphGraphFeatures() {
@@ -354,11 +405,6 @@ public final class TinkerGraph implements Graph {
         }
 
         @Override
-        public boolean supportsPersistence() {
-            return false;
-        }
-
-        @Override
         public boolean supportsThreadedTransactions() {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/5aa2886a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java
index cf85f2d..868597c 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/TinkerGraphProvider.java
@@ -21,11 +21,11 @@ package org.apache.tinkerpop.gremlin.tinkergraph;
 import org.apache.commons.configuration.Configuration;
 import org.apache.tinkerpop.gremlin.AbstractGraphProvider;
 import org.apache.tinkerpop.gremlin.LoadGraphWith;
+import org.apache.tinkerpop.gremlin.TestHelper;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.GraphTest;
 import org.apache.tinkerpop.gremlin.structure.VertexProperty;
 import org.apache.tinkerpop.gremlin.structure.io.IoEdgeTest;
-import org.apache.tinkerpop.gremlin.structure.io.IoTest;
 import org.apache.tinkerpop.gremlin.structure.io.IoVertexTest;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedGraphTest;
 import org.apache.tinkerpop.gremlin.structure.util.star.StarGraphTest;
@@ -37,6 +37,7 @@ import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerProperty;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertex;
 import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerVertexProperty;
 
+import java.io.File;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -69,6 +70,11 @@ public class TinkerGraphProvider extends AbstractGraphProvider {
             put(TinkerGraph.CONFIG_VERTEX_PROPERTY_ID, idMaker);
             if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName))
                 put(TinkerGraph.CONFIG_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
+            if (requiresPersistence(test, testMethodName)) {
+                put(TinkerGraph.CONFIG_GRAPH_FORMAT, "gryo");
+                put(TinkerGraph.CONFIG_GRAPH_LOCATION,
+                        TestHelper.makeTestDataPath(test, "temp").getAbsolutePath() + File.separator + testMethodName + ".kryo");
+            }
         }};
     }
 
@@ -76,6 +82,13 @@ public class TinkerGraphProvider extends AbstractGraphProvider {
     public void clear(final Graph graph, final Configuration configuration) throws Exception {
         if (graph != null)
             graph.close();
+
+        // in the even the graph is persisted we need to clean up
+        final String graphLocation = configuration.getString(TinkerGraph.CONFIG_GRAPH_LOCATION, null);
+        if (graphLocation != null) {
+            final File f = new File(graphLocation);
+            f.delete();
+        }
     }
 
     @Override
@@ -84,6 +97,13 @@ public class TinkerGraphProvider extends AbstractGraphProvider {
     }
 
     /**
+     * Determines if a test requires TinkerGraph persistence to be configured with graph location and format.
+     */
+    private static boolean requiresPersistence(final Class<?> test, final String testMethodName) {
+        return test == GraphTest.class && testMethodName.equals("shouldPersistDataOnClose");
+    }
+
+    /**
      * Determines if a test requires a different cardinality as the default or not.
      */
     private static boolean requiresListCardinalityAsDefault(final LoadGraphWith.GraphData loadGraphWith,