OrientDB GraphED - SQL insert edge between two (select vertex RID)s? Or alternative approach for very large import

匿名 (未验证) 提交于 2019-12-03 08:59:04

问题:

For example, two simple vertices in an OrientDB Graph:

orientdb> CREATE DATABASE local:/databases/test admin admin local graph;        Creating database [local:/databases/test] using the storage type [local]... Database created successfully. Current database is: local:/graph1/databases/test orientdb> INSERT INTO V (label,in,out) VALUES ('vertexOne',[],[]);                                                                                                                  Inserted record 'V#6:0{label:vertexOne,in:[0],out:[0]} v0' in 0.001000 sec(s). orientdb> INSERT INTO V (label,in,out) VALUES ('vertexTwo',[],[]); Inserted record 'V#6:1{label:vertexTwo,in:[0],out:[0]} v0' in 0.000000 sec(s). 

Is there a way to create an edge between these two vertexes by only knowing their 'label's, not their 'RID's?

For example (doesn't work):

orientdb> INSERT INTO E (label, in, out) VALUES ('is_connected_to', (SELECT @rid FROM V WHERE label = 'vertexOne'), (SELECT @rid FROM V WHERE label = 'vertexTwo')); Inserted record 'E#7:0{label:is_connected_to,in:null,out:null} v0' in 0.001000 sec(s). 

I've tried 'FLATTEN' as a potential workaround. No luck:

orientdb> INSERT INTO E (label, in, out) VALUES ('is_connected_to', (SELECT FLATTEN(@rid) FROM V WHERE label = 'vertexOne'), (SELECT FLATTEN(@rid) FROM V WHERE label = 'vertexTwo')); Inserted record 'E#7:1{label:is_connected_to,in:null,out:null} v0' in 0.001000 sec(s). 

The edges created are between null and null. No dice.

I was hoping to use OrientDB SQL for this since I have a very large import of connections and the SQL approach seems to be faster.

However, if this isn't possible, any suggestions about an alternative for batch importing edges (roughly 2M)?

Thanks!

回答1:

SQLCreateEdge is probably what you're trying to do:

create edge from (select from V where label = 'vertexOne') to (select from V where label = 'vertexTwo') set label = 'is_connected_to' 

however, for very large import of connections i suggest SQLCreateLink. this gem is suggested here.



回答2:

Bulk edge insert is possible as SQL Bath

begin;   CREATE EDGE E FROM #34:3349  TO #32:3349;   CREATE EDGE E FROM #41:10971 TO #33:3348; commit retry 100; 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!