简体   繁体   English

何时在Titan图形中使用边缘索引?

[英]When do you use Edge Indexes in a Titan Graph?

There seems to be plenty of documentation around creating a Vertex index in Titan: 关于在Titan中创建Vertex索引的文档似乎很多:

mgmt.buildIndex('byNameAndLabel', Vertex.class).addKey(name)

I can't find much documentation about adding Edge indexes, eg: 我找不到太多有关添加Edge索引的文档,例如:

mgmt.buildIndex('byNameAndLabel', Edge.class).addKey(name)

My questions: 我的问题:

  1. When is it appropriate to add an Edge index to a graph? 什么时候向图表添加Edge索引合适?
  2. Will an Edge index be used if it's available in any/all parts of a traversal or only the first time it's encountered? 如果遍历的任何/所有部分都可用或仅在第一次遇到边缘索引时,会使用边缘索引吗?

The second question I guess is related to how the underlying store (in my case Cassandra) will use indexes. 我猜第二个问题与基础存储(以我的情况为Cassandra)如何使用索引有关。 So the question is really "does the graph go back to the underlying store for each part of the traversal and how does that impact its use of indexes?" 因此,问题实际上是“遍历的每个部分,图是否都返回到底层存储,这对索引的使用有何影响?”

Edge indexes should only be vertex centric indexes , not global indexes. 边缘索引只能是以顶点为中心的索引 ,而不能是全局索引。 I no longer have a test environment for Titan, but I'm actually surprised, that this: 我不再有Titan的测试环境,但实际上,我对此感到惊讶:

mgmt.buildIndex('byNameAndLabel', Edge.class).addKey(name)

...still works. ...仍然有效 I thought this was prevented since 0.5.x, because those indexes never behaved like users expected. 我认为从0.5.x开始就禁止这样做,因为这些索引的行为从未像用户期望的那样。

g.E().has("indexedProperty", value)

...can actually lead to long running scan operation. ...实际上可能导致长时间运行的扫描操作。 If I recall correctly, such an edge index stores the id of the edge's out-vertex and the edge id. 如果我没记错的话,这样的边缘索引会存储边缘的外顶点ID和边缘ID。 So the query mentioned before would first load the out-vertex and then scan its edges until it finds the edge with the indexed id. 因此,前面提到的查询将首先加载出顶点,然后扫描其边缘,直到找到具有索引ID的边缘。

In my case, I have unique custom id for each relation. 就我而言,我对每个关系都有唯一的自定义ID。 So I add a global relation index, and gE().has('KEY',value) does use edge index, as of Titan 1.0.0. 因此,我添加了一个全局关系索引,从Titan 1.0.0开始,gE()。has('KEY',value)确实使用了边缘索引。 Other circumstances not tested. 其他情况未经测试。

Titan uses index id and index property value as rowkey, internal relation id as column and external relation id, such as 1g9ocn9jk-1g9ocnaf4-6c5-1g9ocndkw, as value. Titan将索引ID和索引属性值用作行键,将内部关系ID用作列,将外部关系ID(例如1g9ocn9jk-1g9ocnaf4-6c5-1g9ocndkw)用作值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM