【发布时间】:2018-03-07 17:15:50
【问题描述】:
我的 Java 应用程序中有一个图形遍历,在遍历完成后需要 300 毫秒以上来填充路径对象。这很奇怪,因为它只发生在某些特定的遍历上,而其他遍历会立即填满它们的路径。这是使用 Tinkerpop 3.3.1 的 Java 代码示例
我有一个例子,两个顶点通过一条边直接连接。每次我执行这个短暂的遍历,我都会得到很长的处理时间。如果我不执行 fill() 操作,遍历会立即完成。我有其他遍历需要遍历超过 10 条边,它们在
在下面的代码中,我试图找到从“origs”中的顶点到“dests”中的顶点的最短路径,而无需通过集合“避免”中的任何顶点。遍历本身在 1 毫秒内完成,它的 fill() 方法正在消耗时间。
Date startTime = new Date ();
if (! dests.isEmpty ()){
g.V (origs).where (is (P.without (avoids))).
repeat (
out ().
simplePath ().
where (is (P.without (avoids)))
).
until (is (P.within (dests))).
limit (1).
path ().
fill (paths); // This 'fill' is the line that can take > 300ms.
// When fill is removed from the code,
// this all executes within the same milli
}
Date endTime = new Date ();
// Now compare start time and end time
int diff = DateUtil.getMillisBetween (startTime, endTime);
我也尝试过使用 toList() 方法,但这也使得代码执行时间超过 300 毫秒。
【问题讨论】:
标签: java graph-theory gremlin tinkerpop tinkerpop3