【问题标题】:Does SPARQL-Gremlin plugin support Janusgraph?SPARQL-Gremlin 插件是否支持 Janusgraph?
【发布时间】:2021-08-24 09:38:47
【问题描述】:

我正在尝试测试是否可以使用 sparql 查询 janusgraph。所以,我发现一个插件“SPARQL-Gremlin”可以做到这一点。 (至少,医生说它正在工作。) 但是,当我关注文档https://tinkerpop.apache.org/docs/current/reference/#sparql-gremlin 我发现如果当前存储是 TinkGraph,那么 sparql 可以成功运行。但是,如果我将存储解决方案更改为远程(janusgraph),则会收到错误消息。 那么,有没有人基于这个插件和janusgraph成功过呢?


janusgraph@278205e22512:/opt/janusgraph/bin$ ./gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/janusgraph/lib/slf4j-log4j12-1.7.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/janusgraph/lib/logback-classic-1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
plugin activated: janusgraph.imports
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
09:24:32 WARN  org.apache.hadoop.util.NativeCodeLoader  - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.spark
plugin activated: tinkerpop.tinkergraph
plugin activated: tinkerpop.sparql
gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin>
gremlin>
gremlin>
gremlin> :plugin use tinkerpop.sparql
==>tinkerpop.sparql activated
gremlin> graph = EmptyGraph.instance()
==>emptygraph[empty]
gremlin> g = traversal(SparqlTraversalSource).withGraph(graph)
No such property: SparqlTraversalSource for class: Script5
Type ':help' or ':h' for help.
Display stack trace? [yN]y
groovy.lang.MissingPropertyException: No such property: SparqlTraversalSource for class: Script5
        at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65)
        at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:309)
        at Script5.run(Script5.groovy:1)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:674)
        at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:376)
        at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233)
        at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:267)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

'''

【问题讨论】:

  • 我不认为 Gremlin 服务器上执行了 ":plugin use tinkerpop.sparql" 这一行。您是否可以直接从 Gremlin 控制台打开图表(因此无需远程连接到 Gremlin 服务器)?

标签: gremlin


【解决方案1】:

HadoopMarc 的评论表单可能会导致解决您的问题。当您像在 Gremlin 控制台中那样使用它时,您需要确保 sparql-gremlin 位于 Gremlin Server 的类路径中。换句话说,您正在发送 g = traversal(SparqlTraversalSource).withGraph(graph) 的 Gremlin 字符串以在服务器上执行,并且如果 sparql-gremlin 不在其类路径中,则服务器不知道有关 SparqlTraversalSource 的任何信息。

要通过 Gremlin 控制台和 :remote(即发送脚本)实现此功能,我会尝试以下操作:

  1. 在 Gremlin 服务器(即 Janus 服务器)的类路径中获取 sparql-gremlin。您可以使用bin/gremlin-server.sh install org.apache.tinkerpop sparql-gremlin 3.4.12(或您使用的任何版本)做到这一点
  2. 使用在服务器 YAML 文件中为 JanusGraph 配置的 graph 启动服务器
  3. 使用 :remote 与 Gremlin 控制台连接,就像您在示例中所做的那样
  4. 测试 Gremlin Server 是否通过发送仅提交 SparqlTraversalSource 的脚本来获取包,该脚本应返回类名。
  5. 如果上一步有效,您应该可以:traversal(SparqlTraversalSource).withGraph(graph).sparql("SELECT ?....")

如果所有这些都正常工作,那么下一步可能是在 Gremlin 服务器初始化脚本中配置一个特殊的遍历源,该脚本已经使用 SparqlTraversalSource 设置,以便您可以直接从脚本中引用它。

【讨论】:

    猜你喜欢
    • 2011-10-17
    • 1970-01-01
    • 2019-02-14
    • 2017-09-30
    • 2021-08-07
    • 2016-10-19
    • 1970-01-01
    • 2011-05-28
    • 2016-09-09
    相关资源
    最近更新 更多