updated CHANGELOG and optimized AddEdgeStep attachment a bit.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/894e0e81 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/894e0e81 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/894e0e81 Branch: refs/heads/master Commit: 894e0e815bb213528fe659ede87177a4111bc78b Parents: 6bfc1fa Author: Marko A. Rodriguez <[email protected]> Authored: Thu Jul 20 16:22:10 2017 -0600 Committer: Marko A. Rodriguez <[email protected]> Committed: Thu Jul 20 16:22:10 2017 -0600 ---------------------------------------------------------------------- CHANGELOG.asciidoc | 1 + .../process/traversal/step/map/AddEdgeStep.java | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/894e0e81/CHANGELOG.asciidoc ---------------------------------------------------------------------- diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index ab44755..d2d1447 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -28,6 +28,7 @@ TinkerPop 3.2.6 (Release Date: NOT OFFICIALLY RELEASED YET) This release also includes changes from <<release-3-1-8, 3.1.8>>. +* `AddEdgeStep` attaches detached vertices prior to edge creation. * Added graph element GraphSON serializers in Gremlin-Python. * Initialization scripts for Gremlin Server will not timeout. * Added Gremlin.Net. http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/894e0e81/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java index c64f455..5a083cb 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/map/AddEdgeStep.java @@ -37,6 +37,7 @@ import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.util.Attachable; import org.apache.tinkerpop.gremlin.structure.util.StringFactory; import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedFactory; +import org.apache.tinkerpop.gremlin.structure.util.empty.EmptyGraph; import java.util.List; import java.util.Set; @@ -93,13 +94,12 @@ public final class AddEdgeStep<S> extends MapStep<S, Edge> protected Edge map(final Traverser.Admin<S> traverser) { Vertex toVertex = this.parameters.get(traverser, TO, () -> (Vertex) traverser.get()).get(0); Vertex fromVertex = this.parameters.get(traverser, FROM, () -> (Vertex) traverser.get()).get(0); - if (this.getTraversal().getGraph().isPresent()) { - final Graph graph = this.getTraversal().getGraph().get(); - if (toVertex instanceof Attachable) - toVertex = ((Attachable<Vertex>) toVertex).attach(Attachable.Method.get(graph)); - if (fromVertex instanceof Attachable) - fromVertex = ((Attachable<Vertex>) fromVertex).attach(Attachable.Method.get(graph)); - } + if (toVertex instanceof Attachable) + toVertex = ((Attachable<Vertex>) fromVertex) + .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance()))); + if (fromVertex instanceof Attachable) + fromVertex = ((Attachable<Vertex>) fromVertex) + .attach(Attachable.Method.get(this.getTraversal().getGraph().orElse(EmptyGraph.instance()))); final String edgeLabel = this.parameters.get(traverser, T.label, () -> Edge.DEFAULT_LABEL).get(0); final Edge edge = fromVertex.addEdge(edgeLabel, toVertex, this.parameters.getKeyValues(traverser, TO, FROM, T.label));
