[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user asfgit closed the pull request at: https://github.com/apache/tinkerpop/pull/705 ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r139944071 --- Diff: 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)`. --- End diff -- Please mention that this new class is in `gremlin-test` - "...you can now use `GraphHelper.cloneElements(Graph original, Graph clone)` which is part of the `gremlin-test` module." ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r139944078 --- Diff: 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 --- End diff -- minor - upper case "A" in "added" and end with a period. ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user mpollmeier commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r139550718 --- Diff: 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 +^ --- End diff -- fixed ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r137840681 --- Diff: tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java --- @@ -340,6 +342,14 @@ private void validateHomogenousIds(final List ids) { } } +@Override --- End diff -- A touch of javadoc here to explain that this provide a deep clone of the graph/vertices/edges and preserves ids. ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r137840343 --- Diff: tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java --- @@ -592,6 +592,31 @@ public void shouldSerializeWithColorClassResolverToTinkerGraphUsingDeprecatedTin } } +@Test +public void shouldClone() { +final TinkerGraph g = TinkerGraph.open(); + +Vertex marko = g.addVertex("name", "marko", "age", 29); +Vertex stephen = g.addVertex("name", "stephen", "age", 35); +marko.addEdge("knows", stephen); + +final TinkerGraph g2 = g.clone(); +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()); --- End diff -- perhaps it's a good idea to add an assertion for vertices/edges in the clone showing they are not the same object since it is a deep copy? ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r137840086 --- Diff: tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java --- @@ -592,6 +592,31 @@ public void shouldSerializeWithColorClassResolverToTinkerGraphUsingDeprecatedTin } } +@Test +public void shouldClone() { +final TinkerGraph g = TinkerGraph.open(); + +Vertex marko = g.addVertex("name", "marko", "age", 29); --- End diff -- more need for `final` keyword ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
Github user spmallette commented on a diff in the pull request: https://github.com/apache/tinkerpop/pull/705#discussion_r137839998 --- Diff: tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraph.java --- @@ -340,6 +342,14 @@ private void validateHomogenousIds(final List ids) { } } +@Override +public TinkerGraph clone() { +TinkerGraph cloned = new TinkerGraph(configuration); --- End diff -- please `final` variables as we tend to do that as a style throughout the code base ---
[GitHub] tinkerpop pull request #705: make TinkerGraph cloneable
GitHub user mpollmeier opened a pull request: https://github.com/apache/tinkerpop/pull/705 make TinkerGraph cloneable most people use tinkergraph for testing, and if there are traversals that manipulate the graph, it's useful to be able to clone it up front, especially for larger graphs. You can merge this pull request into a Git repository by running: $ git pull https://github.com/mpollmeier/tinkerpop mp/tinkergraph-clone Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tinkerpop/pull/705.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #705 commit b5c3c1171073d27ed1cda8b77a719b946aa4faaf Author: Michael PollmeierDate: 2017-09-04T08:02:26Z make TinkerGraph cloneable --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---