简体   繁体   English

边和属性的综合索引(tinkerpop / orientDB)

[英]Composite index of edges & property (tinkerpop / orientDB)

I have a graph in OrientDB (uses Tinkerpop stack), and need to enable very fast lookups of edge values / properties / fields and edge in/out vertices. 我在OrientDB中有一个图形(使用Tinkerpop堆栈),需要能够快速查找边缘值/属性/字段和边缘输入/输出顶点。

So, basically the user will need to lookup as follows: 所以,基本上用户需要查找如下:

SELECT FROM myEdges WHERE inVertex = {VertexIdentity}, outVertex = {VertexIdentity}, property1 = 'xyz' SELECT from myEdges WHERE inVertex = {VertexIdentity},outVertex = {VertexIdentity},property1 ='xyz'

Essentially it's a composite index for the edge class, of 3 properties: inVertex, outVertex & property1 本质上,它是边缘类的复合索引,有3个属性:inVertex,outVertex和property1

Basically - if the user already has a VertexIdentity for 2 vertices (maybe, in the form: #CLUSTER_ID:RECORD_ID) - and the the property value (in this case, xyz ) - it will allow very fast lookup to see if the combination already exists in the graph (if 2 vertices are linked with property1) - without making a traversal. 基本上 - 如果用户已经有2个顶点的VertexIdentity(可能,形式为:#CLUSTER_ID:RECORD_ID) - 以及属性值(在本例中为xyz ) - 它将允许非常快速的查找以查看组合是否已经存在于图中(如果2个顶点与property1链接) - 不进行遍历。

So far I found the following code to help with composite indexes, but I cant see if it's possible to include in/out vertices in this (for a graph edge). 到目前为止,我找到了以下代码来帮助复合索引,但我不知道是否可以在此中包含in / out顶点(对于图形边缘)。

https://github.com/orientechnologies/orientdb/blob/master/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectCompositeIndexDirectSearchTest.java https://github.com/orientechnologies/orientdb/blob/master/tests/src/test/java/com/orientechnologies/orient/test/database/auto/SQLSelectCompositeIndexDirectSearchTest.java

Is it possible?? 可能吗??

This is working fine for defining edge uniqueness: 这适用于定义边缘唯一性:

OCommandSQL declareIn= new OCommandSQL();
declareIn.setText("CREATE PROPERTY E.in LINK");
OCommandSQL declareOut= new OCommandSQL();
declareOut.setText("CREATE PROPERTY E.out LINK");
OCommandSQL createIndexUniqueEdge= new OCommandSQL();
createIndexUniqueEdge.setText("CREATE INDEX unique_edge ON E (in, out) UNIQUE");
graph.command(declareIn).execute();
graph.command(declareOut).execute();               
graph.command(createIndexUniqueEdge).execute();

In you case just add another property to the Edge class and consequently in the index 在这种情况下,只需将另一个属性添加到Edge类,然后添加到索引中

You can do it with OrientDB, just create the composite index against the in and out properties too (declare them in E class before). 您可以使用OrientDB执行此操作,只需针对in和out属性创建复合索引(在E类中声明它们之前)。

This is used also as constraints to avoid multiple edges connect the same vertices. 这也用作约束以避免多个边连接相同的顶点。

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

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