Reputation: 3132
I'm trying basic JanusGraph operations on JVM.
When I attempt to simply create an edge between two vertices and calling vertex1.edges()
I'm getting a result of org.janusgraph.graphdb.transaction.RelationConstructor
rather Iterator<Edge>
, which is against api.
I could regenerate the same result on Gremlin console once as shown below. But I'm getting proper org.janusgraph.graphdb.query.ResultSetIterator
in my subsequent attempts.
gremlin> person = graph.addVertex(label, 'person')
==>v[163844144]
gremlin> graph.tx().commit()
==>null
gremlin> person2 = graph.addVertex(label, 'anotherperson')
==>v[245764240]
gremlin> person.addEdge("knows", person2);
==>e[2pjoxy-2pjqy8-29ed-42bkwg][163844144-knows->245764240]
gremlin> graph.tx().commit()
==>null
gremlin> person.class
==>class org.janusgraph.graphdb.vertices.StandardVertex
gremlin> mye = person.edges(Direction.BOTH, "knows")
==>e[2pjoxy-2pjqy8-29ed-42bkwg][163844144-knows->245764240]
gremlin> mye.class
==>class org.janusgraph.graphdb.transaction.RelationConstructor$1$1
Could someone please explain why and/or suggest a workaround? Thank you!
Upvotes: 0
Views: 83
Reputation: 6792
You are getting back class org.janusgraph.graphdb.transaction.RelationConstructor$1$1
. Take notice of the $1$1
which is indicating that you are dealing with an anonymous class within RelationConstructor
. In particular, you are getting back this Iterator
from the method readRelation()
. To be sure, you could have called mye instanceof Iterator
in your session to verify.
In this example below, I've added null
to the end of the mye
assignment to prevent the Gremlin Console auto-iteration behavior.
gremlin> mye = person.edges(Direction.BOTH, "knows"); null
==>null
gremlin> mye instanceof Iterator
==>true
gremlin> myedge = (mye.hasNext()) ? mye.next() : null
==>e[2pjoxy-2pjqy8-29ed-42bkwg][163844144-knows->245764240]
gremlin> myedge.class
==>class org.janusgraph.graphdb.relations.CacheEdge
Upvotes: 3