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 2015/04/08 21:40:19 UTC

incubator-tinkerpop git commit: If an ID does not exist use an incrementing Long.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master fecf6e6db -> 11dbf0c3a


If an ID does not exist use an incrementing Long.


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

Branch: refs/heads/master
Commit: 11dbf0c3aa7ba14be45193981482a8661dafed96
Parents: fecf6e6
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Apr 8 13:40:17 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Apr 8 13:40:17 2015 -0600

----------------------------------------------------------------------
 .../gremlin/structure/util/star/StarGraph.java         | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11dbf0c3/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 fc01dbc..84e59e3 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
@@ -46,7 +46,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
-import java.util.UUID;
+import java.util.Random;
 import java.util.stream.Stream;
 
 /**
@@ -56,6 +56,7 @@ public final class StarGraph implements Graph {
 
     private static final Configuration EMPTY_CONFIGURATION = new BaseConfiguration();
     private StarVertex starVertex = null;
+    private Long nextId = 0l;
 
     @Override
     public Vertex addVertex(final Object... keyValues) {
@@ -172,6 +173,10 @@ public final class StarGraph implements Graph {
                 graph.starVertex.addInEdge(edge.label(), edge.outVertex(), keyValues.toArray(new Object[keyValues.size()]));
     }
 
+    protected Long generateId() {
+        return this.nextId++;
+    }
+
     ///////////////////////
     //// STAR ELEMENT ////
     //////////////////////
@@ -242,7 +247,7 @@ public final class StarGraph implements Graph {
                 outE = new ArrayList<>();
                 this.outEdges.put(label, outE);
             }
-            final StarEdge outEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), label, inVertex.id(), Direction.OUT);
+            final StarEdge outEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(generateId()), label, inVertex.id(), Direction.OUT);
             ElementHelper.attachProperties(outEdge, keyValues);
             outE.add(outEdge);
             return outEdge;
@@ -254,7 +259,7 @@ public final class StarGraph implements Graph {
                 inE = new ArrayList<>();
                 this.inEdges.put(label, inE);
             }
-            final StarEdge inEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), label, outVertex.id(), Direction.IN);
+            final StarEdge inEdge = new StarEdge(ElementHelper.getIdValue(keyValues).orElse(generateId()), label, outVertex.id(), Direction.IN);
             ElementHelper.attachProperties(inEdge, keyValues);
             inE.add(inEdge);
             return inEdge;
@@ -263,7 +268,7 @@ public final class StarGraph implements Graph {
         @Override
         public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, V value, final Object... keyValues) {
             final List<VertexProperty> list = cardinality.equals(VertexProperty.Cardinality.single) ? new ArrayList<>(1) : this.vertexProperties.getOrDefault(key, new ArrayList<>());
-            final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(UUID.randomUUID()), key, value);
+            final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(generateId()), key, value);
             ElementHelper.attachProperties(vertexProperty, keyValues);
             list.add(vertexProperty);
             this.vertexProperties.put(key, list);