I'm using Tinkerpop Frames to create a set of vertices and edges. Adding a new vertex is simple but retreiving vertices based on type seems a bit difficult.
Assume I have a class A and B and I want to add a new one so:
framedGraph.addVertex(null, A.class);
framedGraph.addVertex(null, B.class);
That's straight forward. But what if I want to retrieve all vertices with type A?
Doing this failed, because it returned all vertices (both A and B).
framedGraph.query().vertices(A.class);
Is there any possible way to do this. I tried to check documentations and test cases with no luck. How can I retreive list of Vertices of type A only
This question looks like it's a duplicate of - How to Find Vertices of Specific class with Tinkerpop Frames (also asked today).
As far as I understand, the Tinkerpop Frame framework acts as a wrapper class around a vertex. The vertex isn't actually stored as the interface class. As such, we need a way to identify the vertex as being of a particular
type.My solution, I added
@TypeFieldand@TypeValueannotations to my Frame classes. Then I use these values to query myFramedGraph.The documentation for these annotations can be found here: https://github.com/tinkerpop/frames/wiki/Typed-Graph
Example Code
Then define the
FramedGraphFactoryby addingTypedGraphModuleBuilderlike this.Then to retrieve vertices of type
PersonI'm not sure this is the most efficient/succinct solution (I'd like to see what @stephen mallette suggests). It's not currently available, but it'd be logical to be able to do something like: