与 gremlin shell 相比,我试图确定 rexster 处理用户定义的 Gremlin 查询的方式似乎存在差异的原因。
我在用:
- rexster-server-2.6.0;
- gremlin-groovy-2.5.0;
- orientdb-community-1.7.9;
我已经加载了一个表示简单层次结构树的图形。每个节点都有一个标记为“父”的边,该边指向其父节点。它是一个 DAG。
我在 Gremlin 中定义了一个用户定义的步骤(通过它的init-scripts加载到 rexster 中),如下所示:
Gremlin.defineStep('children',
[Vertex, Pipe],
{int depth -> _().out('parent').loop(1)
{it.loops < depth}
{it.object != null}
})
在 rexster doghouse 中使用命令行 gremlin 工具时,使用这些命令,我收到以下错误(向右滚动以查看整个错误消息):
gremlin> g.V('type', 'LSNetwork')
==>v[#9:6312]
gremlin> g.V('type', 'LSNetwork').out('parent').out('parent').name
==>Leaf 0
==>Leaf 1
==>Leaf 2
==>Leaf 3
gremlin> g.V('type', 'LSNetwork').children(2)
==>javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: com.tinkerpop.gremlin.groovy.GremlinGroovyPipeline.children() is applicable for argument types: (java.lang.Integer) values: [2]
但是,如果我启动 gremlin.sh,连接到我的图表,定义步骤并执行它,它会完美运行:
gremlin> Gremlin.defineStep('children', [Vertex, Pipe], {int depth -> _().out('parent').loop(1){it.loops < depth}{it.object != null}})
==>null
gremlin> sg=new OrientGraph('remote:localhost/scratch')
==>orientgraph[remote:localhost/scratch]
gremlin> sg.V('type','LSNetwork').children(3).name
==>Spine 0
==>Spine 1
==>Leaf 0
==>Leaf 1
==>Leaf 2
==>Leaf 3
(注意:名称是正确的,也是我期望看到的)。
为什么我的 gremlin 脚本可以在 gremlin 控制台上运行,而不是通过灯泡/rexster?
提前致谢,感谢任何帮助、见解或指向适当文档的指针。