我注意到我的一些边缘以奇怪的格式保存。
以下是一个例子:
orientdb {db=gems}> select out_Authored from developer where ghid = 399335 unwind out_Authored
----+------+---------------------------------------------------------------
# |@CLASS|out_Authored
----+------+---------------------------------------------------------------
0 |null |#17:312286
1 |null |#17:312288
2 |null |Authored{date:2012-03-25 02:51:07 UTC,out:#47:1,in:#49:306155}
3 |null |Authored{date:2012-11-21 00:41:12 UTC,out:#47:1,in:#49:369448}
4 |null |Authored{date:2012-11-20 22:41:01 UTC,out:#47:1,in:#49:369449}
5 |null |Authored{date:2011-11-30 21:09:09 UTC,out:#47:1,in:#49:666948}
6 |null |Authored{date:2012-03-25 02:51:07 UTC,out:#47:1,in:#49:2096436}
7 |null |Authored{date:2012-05-23 20:39:31 UTC,out:#47:1,in:#49:2682556}
8 |null |Authored{date:2012-05-23 20:39:31 UTC,out:#47:1,in:#49:2733007}
----+------+---------------------------------------------------------------
如您所见,只有前两个边缘列出了RID,而其他边缘则返回内容而不是RID。现在,如果我明确询问RID,我会得到以下结果:
orientdb {db=gems}> select out_Authored.@rid from developer where ghid = 399335 unwind out_Authored
----+------+------------
# |@CLASS|out_Authored
----+------+------------
0 |null |#17:312286
1 |null |#17:312288
2 |null |#-1:-1
3 |null |#-1:-1
4 |null |#-1:-1
5 |null |#-1:-1
6 |null |#-1:-1
7 |null |#-1:-1
8 |null |#-1:-1
----+------+------------
首先我认为一些边缘已经保存为轻量级边缘或链接,但后来我注意到如果我直接查询有关边缘类的那些返回RID为-1的边缘,我实际上会收到一个显示的响应边存在,其RID不是-1:
orientdb {db=gems}> select from Authored where in=#49:306155 and out=#47:1
----+----------+--------+-----+----------+-----------------------
# |@RID |@CLASS |out |in |date
----+----------+--------+-----+----------+-----------------------
0 |#17:555831|Authored|#47:1|#49:306155|2012-03-25 02:51:07 UTC
----+----------+--------+-----+----------+-----------------------
我的数据库发生了什么,我该如何解决?
我发现了为什么会发生这种情况。在某个时间点,我决定我需要在边缘强加一个唯一性约束,我按照@Lvca建议here这样做了。那些破碎的边缘是在这个修改后创建的边缘。您可以在下面找到课程说明。
虽然我找到了罪魁祸首,但我仍然不知道如何修复数据,而且,如何在不获得这些灾难性后果的情况下强加边缘唯一性约束。
orientdb {db=gems}> info class Authored
CLASS 'Authored'
Super classes........: [E]
Default cluster......: authored (id=17)
Supported clusters...: authored(17)
Cluster selection....: round-robin
Oversize.............: 0.0
PROPERTIES
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
NAME | TYPE | LINKED TYPE/CLASS | MANDATORY | READONLY | NOT NULL | MIN | MAX | COLLATE |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
in | LINK | Commit | false | false | false | | | default |
out | LINK | Developer | false | false | false | | | default |
-------------------------------+-------------+-------------------------------+-----------+----------+----------+-----------+-----------+----------+
INDEXES (1 altogether)
-------------------------------+----------------+
NAME | PROPERTIES |
-------------------------------+----------------+
Authored.in_out | in (+) |
| out |
-------------------------------+----------------+