在 python 中通过 goblin 将数字传递给 gremlin

passing numbers into gremlin via goblin in python

我想在 gremlin 中重复一些遍历,如下所示:

g.V(1).repeat(out()).times(1)

使用 python 的 goblin 包和默认的 titan11 安装(我认为是 titan+casssandra+gremlin+elasticsearch 但是,这个东西是令人困惑)。

在 python 中,在做了一些特殊的导入之后,我写的内容与上面大致相同:

from gremlin_python import statics
from gremlin_python.process.graph_traversal import __
statics.load_statics(globals())

# ... lots of other badass async python stuff and some networkx stuff etc

sg = g.V(seed_id).repeat(out()).times(1)

(如果您认为可能有帮助,请参阅 https://github.com/mikedewar/graphLearning/blob/master/conditional_traversal.py#L107 了解所有其他细节)

当我使用 goblin 遍历 sg 遍历时,我得到一个 Java 错误,我想是 gremlin:

goblin.exception.GremlinServerError: 597: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.times() is applicable for argument types: (java.lang.Long) values: [1]
Possible solutions: toSet(), size(), min(), take(int), sleep(long), is(java.lang.Object)

所以我想它可能不喜欢我传递给它的整数。

请帮忙!我希望能够在 gremlin 中重复内容。

这是 Goblin 提供的旧 Groovy 转换器实现中的一个错误,目的是提供与 GraphSON 版本 1 的向后兼容性。它导致所有整数都被序列化为 long。因为 times 方法签名需要一个整数,所以这会导致错误。我用这个 commit 修复了它。此修复程序将包含在下一版本中。现在,请从 Github:

安装
pip install git+https://github.com/ZEROFAIL/goblin.git

我知道您不确定这个问题的根源,但也许将来 Github 问题会是一个更好的起点。