例如,OrientDB图中有两个简单的顶点:
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).
是否有办法仅通过了解两个“标签”而不是“ RID”来在这两个顶点之间创建边?
例如(无效):
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).
我已经尝试过将“ FLATTEN”作为一种可能的解决方法。没运气:
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).
创建的边缘之间null和null。没有骰子。
null
我希望为此使用OrientDB SQL,因为我有大量的连接导入,而SQL方法似乎更快。
但是,如果这不可能,关于批量导入边(大约2M)的替代方案有什么建议吗?
SQLCreateEdge可能就是您要尝试执行的操作:
create edge from (select from V where label = 'vertexOne') to (select from V where label = 'vertexTwo') set label = 'is_connected_to'