【问题标题】:User defined gremlin step works in gremlin, but not in rexster用户定义的 gremlin 步骤在 gremlin 中有效,但在 rexster 中无效
【发布时间】:2015-01-25 09:33:08
【问题描述】:

与 gremlin shell 相比,我正在尝试确定 rexster 处理用户定义的 Gremlin 查询的方式似乎存在差异的原因。

我正在使用:

  • rexster-server-2.6.0;
  • gremlin-groovy-2.5.0;
  • orientdb-community-1.7.9;

我已经加载了一个表示简单层次结构树的图形。每个节点都有一个标记为“父”的边,该边指向其父节点。它是一个 DAG。

我在 Gremlin 中定义了一个 user-defined step(通过其 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?

提前致谢,感谢您提供任何帮助、见解或指向适当文档的提示。

【问题讨论】:

    标签: groovy gremlin rexster


    【解决方案1】:

    使用文档中定义的codeveloper 步骤版本时,我没有遇到此问题:

    $ curl "http://localhost:8182/graphs/tinkergraph/tp/gremlin?script=g.v(1).codeveloper.name"
    {"success":true,"results":["josh","peter"],"version":"2.5.0","queryTime":39.294181}
    

    似乎也可以在 Dog House 工作。我最好的猜测是 Rexster 没有找到脚本。您确定您的路径适合&lt;init-scripts&gt; 设置吗?如果正确指定并加载了初始化脚本,您应该会看到此日志条目:

    [INFO] EngineHolder - ScriptEngine initializing with a custom script
    

    ScriptEngine 启动之前你不会看到它,直到你对它提出请求(即像我上面的 curl 命令)才会发生。

    【讨论】:

    • 这很可能是问题的原因。但是我无法成功加载 init.groovy 脚本。我怀疑是基本配置问题。我已将对话转移到here
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多