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/04/13 19:22:34 UTC
[13/43] incubator-tinkerpop git commit: Fix up StarGraph to work
within the context of TINKERPOP3-581
Fix up StarGraph to work within the context of TINKERPOP3-581
Make it so that StartGraph can properly handle g.vertices(v) and g.edges(e1).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/a0fec7a6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/a0fec7a6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/a0fec7a6
Branch: refs/heads/master
Commit: a0fec7a68df53a9224095fc831a633a89560eec0
Parents: 9a877b7
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Apr 9 15:12:36 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Apr 9 15:12:36 2015 -0400
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/util/star/StarGraph.java | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/a0fec7a6/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 335bd16..ee29470 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
@@ -91,6 +91,8 @@ public final class StarGraph implements Graph {
public Iterator<Vertex> vertices(final Object... vertexIds) {
if (null == this.starVertex)
return Collections.emptyIterator();
+ else if (vertexIds.length > 0 && vertexIds[0] instanceof StarVertex)
+ return Stream.of(vertexIds).map(v -> (Vertex) v).iterator(); // todo: maybe do this better - not sure of star semantics here
else if (ElementHelper.idExists(this.starVertex.id(), vertexIds))
return IteratorUtils.of(this.starVertex);
else
@@ -121,7 +123,13 @@ public final class StarGraph implements Graph {
this.starVertex.inEdges.values().stream(),
this.starVertex.outEdges.values().stream())
.flatMap(List::stream)
- .filter(edge -> ElementHelper.idExists(edge.id(), edgeIds))
+ .filter(edge -> {
+ // todo: kinda fishy - need to better nail down how stuff should work here - none of these feel consistent right now.
+ if (edgeIds.length > 0 && edgeIds[0] instanceof Edge)
+ return ElementHelper.idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray());
+ else
+ return ElementHelper.idExists(edge.id(), edgeIds);
+ })
.iterator();
}