You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/05/04 17:48:25 UTC
[4/8] incubator-tinkerpop git commit: if the vertex is already a
StarVertex,
then StarGraph.of(vertex) simply returns vertex.graph(). This halfs the object
creation and memory footprint of VertexWritable heading to a GraphWriter.
Also, VertexWritable aut
if the vertex is already a StarVertex, then StarGraph.of(vertex) simply returns vertex.graph(). This halfs the object creation and memory footprint of VertexWritable heading to a GraphWriter. Also, VertexWritable automatically converts to StarVertex on construction and set() so that its always a StarVertex being dealt with (no confusions).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/4070af81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/4070af81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/4070af81
Branch: refs/heads/gs-protocol
Commit: 4070af81829069d78a4476db4ec0d23f96056d02
Parents: 3a3f4d3
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Mon May 4 08:37:36 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Mon May 4 08:37:36 2015 -0600
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/util/star/StarGraph.java | 2 ++
.../gremlin/hadoop/structure/io/VertexWritable.java | 10 ++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4070af81/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 04e432d..6a98db1 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
@@ -172,6 +172,8 @@ public final class StarGraph implements Graph, Serializable {
}
public static StarGraph of(final Vertex vertex) {
+ if (vertex instanceof StarVertex) return (StarGraph) vertex.graph();
+ // else convert to a star graph
final StarGraph starGraph = new StarGraph();
final StarVertex starVertex = (StarVertex) starGraph.addVertex(T.id, vertex.id(), T.label, vertex.label());
vertex.properties().forEachRemaining(vp -> {
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4070af81/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
index f13f9e8..9cd0019 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/VertexWritable.java
@@ -38,21 +38,23 @@ import java.io.Serializable;
*/
public final class VertexWritable implements Writable, Serializable {
- private Vertex vertex;
+ private StarGraph.StarVertex vertex;
public VertexWritable() {
}
public VertexWritable(final Vertex vertex) {
- this.vertex = vertex;
+ this.set(vertex);
}
public void set(final Vertex vertex) {
- this.vertex = vertex;
+ this.vertex = vertex instanceof StarGraph.StarVertex ?
+ (StarGraph.StarVertex) vertex :
+ StarGraph.of(vertex).getStarVertex();
}
- public Vertex get() {
+ public StarGraph.StarVertex get() {
return this.vertex;
}