orientDB - 图 - 基于索引查找更新节点

orientDB - graph - updated nodes based on index lookup

我有一个图结构,其中有一个根节点、几个容器节点(我称它们为 lvl1),每个容器节点包含数十万个内容节点 (lvl2)。内容节点可以 link 与任意数量的其他内容节点一起编辑。 Lvl1 节点永远不会 link 彼此和 link 到它们的 lvl2 节点恰好一次。构建图形时,lvl2 节点之间的 links 可能会出现多次,在这种情况下,我需要对 links 进行计数(增加 depth 属性适当的边缘)。而且施工顺序会很随机

我正在寻找一种使用 orientDB 管理该图形结构的有效方法。建立起来很容易,问题是更新 lvl2 节点(添加更多 links)和它们之间的 links。

select 的一种方法可能是标准的 SQL 查询,类似于 SELECT FROM lvl2nodes WHERE id = 114 - 但是这会查询整个数据集并且非常慢,据我所知看(我还没有测试)。

所以我的想法是使用索引查找。我创建了自动索引 CREATE INDEX lvl2node.id UNIQUE 并尝试查询:SELECT FROM INDEX:lvl2node.id WHERE key = 114,这给了我一个元组 ({:key 114, :rid #<ODocument lvl2node#8:1{id:114,in:[2],out:[1]} v1>}).

现在,我怎样才能

a) 使用该信息 select 一个节点并更新其属性

b) 找到2个这样的顶点之间的边以类似地执行更新

或者是否有更好的方法来更新图的顶点,利用图结构?一个 lvl1 节点仍将包含很多 links,如果没有 hash-map 的方法,这些将需要遍历。

我正在使用 Clojure 的 clj-orient API 来访问 orientDB。

orientdb wiki 中所述:

[...] "When you've millions of records indexes show their limitation 
because the cost to find the records is O(logN). This is also the main 
reason why Relational DBMS are so slow with huge database.

So when you've millions of record the best way to scale up linearly 
is  avoid using indexes at all or as much as you can. But how to  
retrieve records in short time without indexes? Should OrientDB scan 
the entire database at every query? No. You should use the Graph 
properties of OrientDB."

我个人会像他们对时间序列用例那样对树使用链接映射。

看起来像这样:

create class lvl1
create class lvl2
create class lvl3

create property lvl1.id integer
create property lvl1.lvl2 linkmap lvl2
create property lvl2.lvl3 linkmap lvl3

链接图中的键将是下一级节点 ID。要获得深度,您将使用下一级链接映射 属性.

的长度 属性