Gremlin Query for Retrieving the Full Tree

122 views
Skip to first unread message

Harinder Singh

unread,
Mar 24, 2022, 11:16:56 AM3/24/22
to Gremlin-users
Hi Everyone,

I am using Janusgraph with Cassandra. Graph Structure is attached 

Page ----child---> Instance

Instance -----> targets -----> Segment (can be more than 1)
instance -----> emdeds -----> Fragment (can be more than 1)
Fragment -----> child -------> FragmentInstance
Fragment -----> targets -----> Segment (Can be more than 1)

The query will start from Page (V1) and need to return the full tree such as
v1,v2,v3,v4,v5,v6,v7 // their ids will suffice.

Query : g.V().has('docId','page1').emit().repeat(out()).tree()

This prints all vertices but it prints duplicates as well in case the segment is shared between instance and fragment Instance.
Another thing is this query is very slow for higher number of vertices. Took somewhere 14 seconds.

I have one index for lookup by docId.


Is there some other alternative to this query which can just print the vertices and also reduce latency. Looking under 10ms

graph.jpg

Stephen Mallette

unread,
Mar 28, 2022, 7:07:13 AM3/28/22
to gremli...@googlegroups.com
When you need to get a "full tree" performance often suffers as you simply have to traverse a greater number of paths to collect the tree. There may not be much you can do in these cases from a Gremlin level, short of issuing traversals in parallel that might traverse the tree in different directions to collect its entirety and then re-constituting it on your own in your application layer. Depending on the nature of your data/requirements that may or may not be possible and it obviously takes a really simple Gremlin traversal and turns it into something more complicated. 

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/e505ce19-cc22-413e-b44e-a71ea671ee7an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages