OrientDB图形-SQL在两个(选择顶点RID)之间插入边?或大量进口的替代方法 [英] OrientDB GraphED - SQL insert edge between two (select vertex RID)s? Or alternative approach for very large import

查看:141
本文介绍了OrientDB图形-SQL在两个(选择顶点RID)之间插入边?或大量进口的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,在OrientDB图形中有两个简单的顶点:

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).

是否有一种方法可以通过仅知道它们的标签而不是它们的顶点来在这两个顶点之间创建边缘'RID's?

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

例如(无效):

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作为一种可能的解决方法。没有运气:

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).

创建的边在 null null 。没有骰子。

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

我希望为此使用OrientDB SQL,因为我导入了大量连接,而SQL方法似乎更快。

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.

但是,如果不可能,关于批量导入边缘的替代方案(大约2M)有什么建议吗?

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

推荐答案

SQLCreateEdge 可能就是您要尝试的做:

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'

但是,对于大量导入的连接,我建议 SQLCreateLink 。建议在此处

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

这篇关于OrientDB图形-SQL在两个(选择顶点RID)之间插入边?或大量进口的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆