You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/12 14:13:22 UTC

[1/2] tinkerpop git commit: TINKERPOP-1397 Fix StarGraph.addEdge

Repository: tinkerpop
Updated Branches:
  refs/heads/tp31 6d2939422 -> 2720b97d6


TINKERPOP-1397 Fix StarGraph.addEdge

For self-loops, StarGraph.addEdge used to put a single StarOutEdge
into both its inEdges and outEdges maps, potentially causing problems
in applyGraphFilter.

This change makes StarGraph.addEdge put the appropriate type of edge
(Star(Out/In)Edge) in the associated map.  The IDs for each edge
instance are kept in agreement.

This change is @okram's, who suggested it in PR #372.  I merely
reviewed it and added a couple of comments.


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

Branch: refs/heads/tp31
Commit: 0022b7f6be25eb7d3c778b137beb6e8a7d2784ca
Parents: 4571061
Author: Dan LaRocque <da...@hopcount.org>
Authored: Wed Aug 10 18:52:13 2016 -0400
Committer: Dan LaRocque <da...@hopcount.org>
Committed: Wed Aug 10 19:10:39 2016 -0400

----------------------------------------------------------------------
 .../gremlin/structure/util/star/StarGraph.java     | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0022b7f6/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index f516630..2089c42 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -37,6 +37,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -290,14 +291,16 @@ public final class StarGraph implements Graph, Serializable {
         public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
             final Edge edge = this.addOutEdge(label, inVertex, keyValues);
             if (inVertex.equals(this)) {
-                if(null == this.inEdges)
-                    this.inEdges = new HashMap<>();
-                List<Edge> inE = this.inEdges.get(label);
-                if (null == inE) {
-                    inE = new ArrayList<>();
-                    this.inEdges.put(label, inE);
+                if (ElementHelper.getIdValue(keyValues).isPresent()) {
+                    // reuse edge ID from method params
+                    this.addInEdge(label, this, keyValues);
+                } else {
+                    // copy edge ID that we just allocated with addOutEdge
+                    final Object[] keyValuesWithId = Arrays.copyOf(keyValues, keyValues.length + 2);
+                    keyValuesWithId[keyValuesWithId.length - 2] = T.id;
+                    keyValuesWithId[keyValuesWithId.length - 1] = edge.id();
+                    this.addInEdge(label, this, keyValuesWithId);
                 }
-                inE.add(edge);
             }
             return edge;
         }


[2/2] tinkerpop git commit: Merge branch 'TINKERPOP-1397-tp31' of https://github.com/dalaro/incubator-tinkerpop into tp31

Posted by ok...@apache.org.
Merge branch 'TINKERPOP-1397-tp31' of https://github.com/dalaro/incubator-tinkerpop into tp31


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

Branch: refs/heads/tp31
Commit: 2720b97d62d827cf82ffad93715dfa261e34d8d8
Parents: 6d29394 0022b7f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Aug 12 08:06:23 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Aug 12 08:06:23 2016 -0600

----------------------------------------------------------------------
 .../gremlin/structure/util/star/StarGraph.java     | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------