How can Multiple Vertex-Centric Indexes Be Built for the Same Edge Label in JanusGraph

69 views
Skip to first unread message

Jun Li

unread,
Sep 20, 2019, 4:46:31 AM9/20/19
to JanusGraph users

Hi: 

 

In the JanusGraph documentation, https://docs.janusgraph.org/basics/index-performance/, the section on "Vertex-Centric Indexes", there is the following paragraph:

 

"Multiple vertex-centric indexes can be built for the same edge label in order to support different constraint traversals. JanusGraph’s query optimizer attempts to pick the most efficient index for any given traversal."

 

Then I went to review the JanusGraph Data Model in the JanusGraph documentation, https://docs.janusgraph.org/advanced-topics/data-model/, there is a section of “Individual Edge Layout” along with a diagram to show the key/column/value layout.   One edge that is associated with a vertex can only be stored as a unique “edge” cell in a row that belongs to the vertex.  And in this cell, the column key is encoded as: label id + direction + sort key + adjacent vertex id + edge id, and the column value is encoded as: signature key + other (cell) properties.

 

My understanding is that for a unique edge, with only one column key, there can only be one single label id and the associated sort key to be supported.  Therefore, one edge can only be encoded with one edge label, and one vertex-centric index (represented by the sort key) belonging to this edge label. 

 

My question is: how can multiple vertex-centric indexes to be supported, given the current JanusGraph Data Model?

 

If I remember correctly, this multiple vertex-centric indexes support statement did not appear in the older version of JanusGraph documentation (say, before January 2019). And the JanusGraph data model has stayed the same without changes since the beginning of JanusGraph. 

 

Jun

Jerry He

unread,
Sep 23, 2019, 7:03:02 PM9/23/19
to JanusGraph users list, JanusGraph developer list
Hi, Jun

This is a good question. Let me try to answer it. 

As you see in the document, multiple vertex-centric indexes can be defined on the same edge type/label.  Under the hook, for each vertex-centric index, JanusGraph will create an 'artificial' edge label, and columns will be created/added to the vertex (the same way as you mentioned for the regular column:  label id + direction + sort key + adjacent vertex id + edge id).  For example, if you create an edge index call 'myindex' for the edge label 'friend', the artificial edge label will be called 'friend:myindex' (the name is actually long id).  Then artificial edges (index edges) with this label will be added to the vertex node. The sort keys are the properties defined in the index.  In such way, there is no conflict or problem with defining multiple such vertex-centric indexes.

Thanks,

Jerry

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/janusgraph-users/e3ded08f-b5a0-4a53-bc78-dd66c696d39d%40googlegroups.com.

Jun Li

unread,
Sep 23, 2019, 9:33:17 PM9/23/19
to JanusGraph users
Hi Jerry,

Thanks for the explanation. I wonder when such "artificial edge label" gets introduced into the JanusGraph release? Could you point me to the source code files in the recent release on handling vertex-centric index with  such an artificial label? 

Regards,

Jun

Jerry He

unread,
Sep 24, 2019, 1:58:57 PM9/24/19
to JanusGraph users list
Hi, Jun

The methods buildEdgeIndex and buildRelationTypeIndex are here:

You can also see how the RelationTypeIndex (vertex centric index) edges are added/updated in the JanusGraph transaction and index repair tool code.

Thanks,

Jerry

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgraph-use...@googlegroups.com.

Nguyen Trung Hieu

unread,
Dec 11, 2019, 7:25:38 PM12/11/19
to JanusGraph users
Hi Jerry,

That is interesting to know. If I have one edge with type/label "routes" that has 3 vertex-centric indices as below:

management.buildEdgeIndex(routes, "idx_vertex_centric_distance", Direction.BOTH, distance);
management.buildEdgeIndex(routes, "idx_vertex_centric_age", Direction.BOTH, age);
management.buildEdgeIndex(routes, "idx_vertex_centric_distance_age", Direction.BOTH, distance, age);

where distance and age are property keys of the edges, does that mean that if I create such an edge between two vertices, under the hook 3 key-value pairs will be created? Moreover, those three are nearly identical, the only difference is their labels: one is "routes:idx_vertex_centric_distance", another is "routes:idx_vertex_centric_age" and another is "routes:idx_vertex_centric_distance_age"?

If this is the case, an update to the age property of this edge needs to update all these 3 key-value pairs. Correct?


On Tuesday, September 24, 2019 at 10:58:57 AM UTC-7, Jerry He wrote:
Hi, Jun

The methods buildEdgeIndex and buildRelationTypeIndex are here:

You can also see how the RelationTypeIndex (vertex centric index) edges are added/updated in the JanusGraph transaction and index repair tool code.

Thanks,

Jerry

On Mon, Sep 23, 2019 at 6:33 PM Jun Li <jltz9...@gmail.com> wrote:
Hi Jerry,

Thanks for the explanation. I wonder when such "artificial edge label" gets introduced into the JanusGraph release? Could you point me to the source code files in the recent release on handling vertex-centric index with  such an artificial label? 

Regards,

Jun

--
You received this message because you are subscribed to the Google Groups "JanusGraph users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to janusgra...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages