You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by mp...@apache.org on 2017/09/21 02:15:35 UTC
[1/7] tinkerpop git commit: move implementation of clone to
GraphHelper
Repository: tinkerpop
Updated Branches:
refs/heads/master fc48b046c -> c60cb9e74
move implementation of clone to GraphHelper
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9bf5f636
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9bf5f636
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9bf5f636
Branch: refs/heads/master
Commit: 9bf5f636eb46f2ae3a8869b3373134ffd94ebb70
Parents: a44e881
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Mon Sep 11 10:53:40 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:08:27 2017 +1200
----------------------------------------------------------------------
gremlin-core/pom.xml | 6 ++
.../gremlin/structure/util/GraphHelper.java | 39 +++++++++++++
.../gremlin/structure/util/GraphHelperTest.java | 59 ++++++++++++++++++++
.../tinkergraph/structure/TinkerGraph.java | 17 +-----
.../tinkergraph/structure/TinkerGraphTest.java | 30 ----------
5 files changed, 105 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf5f636/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index bab7b65..e690c5d 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -95,6 +95,12 @@ limitations under the License.
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.tinkerpop</groupId>
+ <artifactId>tinkergraph-gremlin</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- needed to test GraphFactory and xml based config via optional dependency in apache configurations -->
<dependency>
<groupId>commons-collections</groupId>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf5f636/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
new file mode 100644
index 0000000..5d4809c
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
@@ -0,0 +1,39 @@
+/*
+ * 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.structure.util;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+
+/**
+ * Utility class supporting common functions for {@link org.apache.tinkerpop.gremlin.structure.Graph}.
+ */
+public final class GraphHelper {
+
+ private GraphHelper() {
+ }
+
+ /**
+ * make a deep clone of the graph elements that preserves ids
+ */
+ public static void cloneElements(final Graph original, final Graph clone) {
+ original.vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(clone)));
+ original.edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(clone)));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf5f636/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
new file mode 100644
index 0000000..c186caf
--- /dev/null
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.structure.util;
+
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class GraphHelperTest {
+
+ @Test
+ public void shouldCloneTinkergraph() {
+ final TinkerGraph original = TinkerGraph.open();
+ final TinkerGraph clone = TinkerGraph.open();
+
+ final Vertex marko = original.addVertex("name", "marko", "age", 29);
+ final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
+ marko.addEdge("knows", stephen);
+ GraphHelper.cloneElements(original, clone);
+
+ final Vertex michael = clone.addVertex("name", "michael");
+ michael.addEdge("likes", marko);
+ michael.addEdge("likes", stephen);
+ clone.traversal().V().property("newProperty", "someValue").toList();
+ clone.traversal().E().property("newProperty", "someValue").toList();
+
+ assertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
+ assertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
+ assertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
+
+ assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
+ assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
+
+ assertNotSame("cloned elements should reference to different objects",
+ original.traversal().V().has("name", "stephen").next(),
+ clone.traversal().V().has("name", "stephen").next());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf5f636/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 6501663..5563665 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
@@ -30,13 +30,9 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
-import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
-import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoVersion;
-import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputerView;
import org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.optimization.TinkerGraphCountStrategy;
@@ -74,7 +70,7 @@ import java.util.stream.Stream;
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE)
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_PERFORMANCE)
-public final class TinkerGraph implements Graph, Cloneable {
+public final class TinkerGraph implements Graph {
static {
TraversalStrategies.GlobalCache.registerStrategies(TinkerGraph.class, TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(
@@ -382,17 +378,6 @@ public final class TinkerGraph implements Graph, Cloneable {
}
}
- /**
- * make a deep clone of the graph/vertices/edges that preserves ids
- */
- @Override
- public TinkerGraph clone() {
- final TinkerGraph cloned = new TinkerGraph(configuration);
- vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(cloned)));
- edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(cloned)));
- return cloned;
- }
-
public class TinkerGraphFeatures implements Features {
private final TinkerGraphGraphFeatures graphFeatures = new TinkerGraphGraphFeatures();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9bf5f636/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 cb4f4d7..a85b0ee 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
@@ -68,7 +68,6 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -594,35 +593,6 @@ public class TinkerGraphTest {
}
}
- @Test
- public void shouldClone() {
- final TinkerGraph g = TinkerGraph.open();
-
- final Vertex marko = g.addVertex("name", "marko", "age", 29);
- final Vertex stephen = g.addVertex("name", "stephen", "age", 35);
- marko.addEdge("knows", stephen);
-
- final TinkerGraph g2 = g.clone();
- final Vertex michael = g2.addVertex("name", "michael");
- michael.addEdge("likes", marko);
- michael.addEdge("likes", stephen);
- g2.traversal().V().property("newProperty", "someValue").toList();
- g2.traversal().E().property("newProperty", "someValue").toList();
-
- assertEquals("original graph should be unchanged", new Long(2), g.traversal().V().count().next());
- assertEquals("original graph should be unchanged", new Long(1), g.traversal().E().count().next());
- assertEquals("original graph should be unchanged", new Long(0), g.traversal().V().has("newProperty").count().next());
-
- assertEquals("cloned graph should contain new elements", new Long(3), g2.traversal().V().count().next());
- assertEquals("cloned graph should contain new elements", new Long(3), g2.traversal().E().count().next());
- assertEquals("cloned graph should contain new property", new Long(3), g2.traversal().V().has("newProperty").count().next());
- assertEquals("cloned graph should contain new property", new Long(3), g2.traversal().E().has("newProperty").count().next());
-
- assertNotSame("cloned elements should reference to different objects",
- g.traversal().V().has("name", "stephen").next(),
- g2.traversal().V().has("name", "stephen").next());
- }
-
/**
* Coerces a {@code Color} to a {@link TinkerGraph} during serialization. Demonstrates how custom serializers
* can be developed that can coerce one value to another during serialization.
[2/7] tinkerpop git commit: make TinkerGraph cloneable
Posted by mp...@apache.org.
make TinkerGraph cloneable
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a44e8815
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a44e8815
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a44e8815
Branch: refs/heads/master
Commit: a44e881533a29231752ed4884d3a87c63bf4befc
Parents: 132011f
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Mon Sep 4 20:02:26 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:08:27 2017 +1200
----------------------------------------------------------------------
.../tinkergraph/structure/TinkerGraph.java | 17 ++++++++++-
.../tinkergraph/structure/TinkerGraphTest.java | 30 ++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a44e8815/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 5563665..6501663 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
@@ -30,9 +30,13 @@ import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.apache.tinkerpop.gremlin.structure.io.Io;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
+import org.apache.tinkerpop.gremlin.structure.io.gryo.GryoVersion;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
import org.apache.tinkerpop.gremlin.structure.util.StringFactory;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputer;
import org.apache.tinkerpop.gremlin.tinkergraph.process.computer.TinkerGraphComputerView;
import org.apache.tinkerpop.gremlin.tinkergraph.process.traversal.strategy.optimization.TinkerGraphCountStrategy;
@@ -70,7 +74,7 @@ import java.util.stream.Stream;
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT)
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_INTEGRATE)
@Graph.OptIn(Graph.OptIn.SUITE_GROOVY_ENVIRONMENT_PERFORMANCE)
-public final class TinkerGraph implements Graph {
+public final class TinkerGraph implements Graph, Cloneable {
static {
TraversalStrategies.GlobalCache.registerStrategies(TinkerGraph.class, TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(
@@ -378,6 +382,17 @@ public final class TinkerGraph implements Graph {
}
}
+ /**
+ * make a deep clone of the graph/vertices/edges that preserves ids
+ */
+ @Override
+ public TinkerGraph clone() {
+ final TinkerGraph cloned = new TinkerGraph(configuration);
+ vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(cloned)));
+ edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(cloned)));
+ return cloned;
+ }
+
public class TinkerGraphFeatures implements Features {
private final TinkerGraphGraphFeatures graphFeatures = new TinkerGraphGraphFeatures();
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a44e8815/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 a85b0ee..cb4f4d7 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
@@ -68,6 +68,7 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -593,6 +594,35 @@ public class TinkerGraphTest {
}
}
+ @Test
+ public void shouldClone() {
+ final TinkerGraph g = TinkerGraph.open();
+
+ final Vertex marko = g.addVertex("name", "marko", "age", 29);
+ final Vertex stephen = g.addVertex("name", "stephen", "age", 35);
+ marko.addEdge("knows", stephen);
+
+ final TinkerGraph g2 = g.clone();
+ final Vertex michael = g2.addVertex("name", "michael");
+ michael.addEdge("likes", marko);
+ michael.addEdge("likes", stephen);
+ g2.traversal().V().property("newProperty", "someValue").toList();
+ g2.traversal().E().property("newProperty", "someValue").toList();
+
+ assertEquals("original graph should be unchanged", new Long(2), g.traversal().V().count().next());
+ assertEquals("original graph should be unchanged", new Long(1), g.traversal().E().count().next());
+ assertEquals("original graph should be unchanged", new Long(0), g.traversal().V().has("newProperty").count().next());
+
+ assertEquals("cloned graph should contain new elements", new Long(3), g2.traversal().V().count().next());
+ assertEquals("cloned graph should contain new elements", new Long(3), g2.traversal().E().count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), g2.traversal().V().has("newProperty").count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), g2.traversal().E().has("newProperty").count().next());
+
+ assertNotSame("cloned elements should reference to different objects",
+ g.traversal().V().has("name", "stephen").next(),
+ g2.traversal().V().has("name", "stephen").next());
+ }
+
/**
* Coerces a {@code Color} to a {@link TinkerGraph} during serialization. Demonstrates how custom serializers
* can be developed that can coerce one value to another during serialization.
[7/7] tinkerpop git commit: Merge branch 'tp32'
Posted by mp...@apache.org.
Merge branch 'tp32'
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c60cb9e7
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c60cb9e7
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c60cb9e7
Branch: refs/heads/master
Commit: c60cb9e7493c2285e5d85215f849638bda2460b9
Parents: fc48b04 615026c
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Thu Sep 21 14:15:19 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:15:19 2017 +1200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../upgrade/release-3.2.x-incubating.asciidoc | 4 ++
.../apache/tinkerpop/gremlin/GraphHelper.java | 40 ++++++++++++++++++++
.../tinkergraph/structure/TinkerGraphTest.java | 32 ++++++++++++++++
4 files changed, 77 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c60cb9e7/CHANGELOG.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c60cb9e7/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c60cb9e7/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
[5/7] tinkerpop git commit: minor fixes to changelog
Posted by mp...@apache.org.
minor fixes to changelog
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/67db5e8e
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/67db5e8e
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/67db5e8e
Branch: refs/heads/master
Commit: 67db5e8eb54265b2f379c7aade7c44d3b5ed009b
Parents: 3d0cd1a
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Thu Sep 21 14:06:23 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:09:22 2017 +1200
----------------------------------------------------------------------
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/67db5e8e/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 9b576f9..96017b4 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -90,8 +90,7 @@ See: link:https://issues.apache.org/jira/browse/TINKERPOP-1764[TINKERPOP-1764]
Clone a graph
^^^^^^^^^^^^^
-If you want to quickly clone a graph (e.g. because you have set it up in a test and your traversals manipulate the graph) you can now use `GraphHelper.cloneElements(Graph original, Graph clone)`.
-
+If you want to quickly clone a graph (e.g. because you have set it up in a test and your traversals manipulate the graph) you can now use `GraphHelper.cloneElements(Graph original, Graph clone)` which is part of the gremlin-test module.
TinkerPop 3.2.6
---------------
[6/7] tinkerpop git commit: Merge branch 'mp/tinkergraph-clone' into
tp32
Posted by mp...@apache.org.
Merge branch 'mp/tinkergraph-clone' into tp32
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/615026ce
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/615026ce
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/615026ce
Branch: refs/heads/master
Commit: 615026cef35f1ae76bb999bdcd6f6faeab2020df
Parents: 132011f 67db5e8
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Thu Sep 21 14:13:26 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:13:26 2017 +1200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../upgrade/release-3.2.x-incubating.asciidoc | 4 ++
.../apache/tinkerpop/gremlin/GraphHelper.java | 40 ++++++++++++++++++++
.../tinkergraph/structure/TinkerGraphTest.java | 32 ++++++++++++++++
4 files changed, 77 insertions(+)
----------------------------------------------------------------------
[4/7] tinkerpop git commit: update changelog and upgrade logs
Posted by mp...@apache.org.
update changelog and upgrade logs
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/f6d0a2c3
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/f6d0a2c3
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/f6d0a2c3
Branch: refs/heads/master
Commit: f6d0a2c36a36ea3af44f507bf3340d19fac0da96
Parents: 9bf5f63
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Mon Sep 11 11:00:13 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:08:55 2017 +1200
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
docs/src/upgrade/release-3.2.x-incubating.asciidoc | 5 +++++
2 files changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6d0a2c3/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 453552a..64d4167 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.2.7 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Added `GraphHelper.cloneElements(Graph original, Graph clone)` to quickly clone a graph.
* Bump to GMavenPlus 1.6.
* Added better error message for illegal use of `repeat()`-step.
* Bump to Jackson 2.8.10.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/f6d0a2c3/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index ae504d4..9b576f9 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -88,6 +88,11 @@ to the list of locally computed clauses.
See: link:https://issues.apache.org/jira/browse/TINKERPOP-1764[TINKERPOP-1764]
+Clone a graph
+^^^^^^^^^^^^^
+If you want to quickly clone a graph (e.g. because you have set it up in a test and your traversals manipulate the graph) you can now use `GraphHelper.cloneElements(Graph original, Graph clone)`.
+
+
TinkerPop 3.2.6
---------------
[3/7] tinkerpop git commit: resolve cyclic dependency by moving
GraphHelper to gremlin-test
Posted by mp...@apache.org.
resolve cyclic dependency by moving GraphHelper to gremlin-test
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3d0cd1a9
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3d0cd1a9
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3d0cd1a9
Branch: refs/heads/master
Commit: 3d0cd1a959b37ff3a829138859558ce1bcc90191
Parents: f6d0a2c
Author: Michael Pollmeier <mi...@michaelpollmeier.com>
Authored: Mon Sep 18 16:38:48 2017 +1200
Committer: Michael Pollmeier <mi...@michaelpollmeier.com>
Committed: Thu Sep 21 14:08:55 2017 +1200
----------------------------------------------------------------------
gremlin-core/pom.xml | 6 --
.../gremlin/structure/util/GraphHelper.java | 39 -------------
.../gremlin/structure/util/GraphHelperTest.java | 59 --------------------
.../apache/tinkerpop/gremlin/GraphHelper.java | 40 +++++++++++++
.../tinkergraph/structure/TinkerGraphTest.java | 32 +++++++++++
5 files changed, 72 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/pom.xml
----------------------------------------------------------------------
diff --git a/gremlin-core/pom.xml b/gremlin-core/pom.xml
index e690c5d..bab7b65 100644
--- a/gremlin-core/pom.xml
+++ b/gremlin-core/pom.xml
@@ -95,12 +95,6 @@ limitations under the License.
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.apache.tinkerpop</groupId>
- <artifactId>tinkergraph-gremlin</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
<!-- needed to test GraphFactory and xml based config via optional dependency in apache configurations -->
<dependency>
<groupId>commons-collections</groupId>
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
deleted file mode 100644
index 5d4809c..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelper.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.structure.util;
-
-import org.apache.tinkerpop.gremlin.structure.Graph;
-import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
-
-/**
- * Utility class supporting common functions for {@link org.apache.tinkerpop.gremlin.structure.Graph}.
- */
-public final class GraphHelper {
-
- private GraphHelper() {
- }
-
- /**
- * make a deep clone of the graph elements that preserves ids
- */
- public static void cloneElements(final Graph original, final Graph clone) {
- original.vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(clone)));
- original.edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(clone)));
- }
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
deleted file mode 100644
index c186caf..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/util/GraphHelperTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.structure.util;
-
-import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class GraphHelperTest {
-
- @Test
- public void shouldCloneTinkergraph() {
- final TinkerGraph original = TinkerGraph.open();
- final TinkerGraph clone = TinkerGraph.open();
-
- final Vertex marko = original.addVertex("name", "marko", "age", 29);
- final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
- marko.addEdge("knows", stephen);
- GraphHelper.cloneElements(original, clone);
-
- final Vertex michael = clone.addVertex("name", "michael");
- michael.addEdge("likes", marko);
- michael.addEdge("likes", stephen);
- clone.traversal().V().property("newProperty", "someValue").toList();
- clone.traversal().E().property("newProperty", "someValue").toList();
-
- assertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
- assertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
- assertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
-
- assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
- assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
- assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
- assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
-
- assertNotSame("cloned elements should reference to different objects",
- original.traversal().V().has("name", "stephen").next(),
- clone.traversal().V().has("name", "stephen").next());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
new file mode 100644
index 0000000..24393be
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/GraphHelper.java
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.util.Attachable;
+import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory;
+
+/**
+ * Utility class supporting common functions for {@link org.apache.tinkerpop.gremlin.structure.Graph}.
+ */
+public final class GraphHelper {
+
+ private GraphHelper() {
+ }
+
+ /**
+ * make a deep clone of the graph elements that preserves ids
+ */
+ public static void cloneElements(final Graph original, final Graph clone) {
+ original.vertices().forEachRemaining(v -> DetachedFactory.detach(v, true).attach(Attachable.Method.create(clone)));
+ original.edges().forEachRemaining(e -> DetachedFactory.detach(e, true).attach(Attachable.Method.create(clone)));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3d0cd1a9/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 a85b0ee..83bbe58 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,6 +20,7 @@ package org.apache.tinkerpop.gremlin.tinkergraph.structure;
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.GraphHelper;
import org.apache.tinkerpop.gremlin.TestHelper;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
@@ -68,6 +69,7 @@ import java.util.function.Consumer;
import java.util.function.Supplier;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
@@ -593,6 +595,36 @@ public class TinkerGraphTest {
}
}
+ @Test
+ public void shouldCloneTinkergraph() {
+ final TinkerGraph original = TinkerGraph.open();
+ final TinkerGraph clone = TinkerGraph.open();
+
+ final Vertex marko = original.addVertex("name", "marko", "age", 29);
+ final Vertex stephen = original.addVertex("name", "stephen", "age", 35);
+ marko.addEdge("knows", stephen);
+ GraphHelper.cloneElements(original, clone);
+
+ final Vertex michael = clone.addVertex("name", "michael");
+ michael.addEdge("likes", marko);
+ michael.addEdge("likes", stephen);
+ clone.traversal().V().property("newProperty", "someValue").toList();
+ clone.traversal().E().property("newProperty", "someValue").toList();
+
+ assertEquals("original graph should be unchanged", new Long(2), original.traversal().V().count().next());
+ assertEquals("original graph should be unchanged", new Long(1), original.traversal().E().count().next());
+ assertEquals("original graph should be unchanged", new Long(0), original.traversal().V().has("newProperty").count().next());
+
+ assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().V().count().next());
+ assertEquals("cloned graph should contain new elements", new Long(3), clone.traversal().E().count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().V().has("newProperty").count().next());
+ assertEquals("cloned graph should contain new property", new Long(3), clone.traversal().E().has("newProperty").count().next());
+
+ assertNotSame("cloned elements should reference to different objects",
+ original.traversal().V().has("name", "stephen").next(),
+ clone.traversal().V().has("name", "stephen").next());
+ }
+
/**
* Coerces a {@code Color} to a {@link TinkerGraph} during serialization. Demonstrates how custom serializers
* can be developed that can coerce one value to another during serialization.