SPARQL-Gremlin 插件是否支持 Janusgraph?
Does SPARQL-Gremlin plugin support Janusgraph?
我正在尝试测试是否可以使用 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[=10=](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)
'''
HadoopMarc 的评论表单可能会解决您的问题。当您以在 Gremlin 控制台中的方式使用它时,您需要确保 sparql-gremlin
在 Gremlin 服务器的类路径中。换句话说,您正在发送要在服务器上执行的 g = traversal(SparqlTraversalSource).withGraph(graph)
的 Gremlin 字符串,如果 sparql-gremlin
不在其类路径中,服务器对 SparqlTraversalSource
一无所知。
要通过 Gremlin 控制台和 :remote
(即发送脚本)使其正常工作,我会尝试以下操作:
- 在 Gremlin 服务器(即 Janus 服务器)的类路径中获取
sparql-gremlin
。您可以使用 bin/gremlin-server.sh install org.apache.tinkerpop sparql-gremlin 3.4.12
(或您使用的任何版本) 来做到最好
- 使用在服务器 YAML 文件中为 JanusGraph 配置的
graph
启动服务器
- 使用
:remote
连接 Gremlin 控制台,就像您在示例中所做的那样
- 通过发送
SparqlTraversalSource
的脚本来测试 Gremlin 服务器是否接收到包,该脚本应该 return 类名。
- 如果前面的步骤有效,您应该能够做到:
traversal(SparqlTraversalSource).withGraph(graph).sparql("SELECT ?....")
如果一切正常,那么下一步可能是在已经使用 SparqlTraversalSource
设置的 Gremlin 服务器初始化脚本中配置一个特殊的遍历源,以便您可以从脚本中引用它直接。
我正在尝试测试是否可以使用 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[=10=](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)
'''
HadoopMarc 的评论表单可能会解决您的问题。当您以在 Gremlin 控制台中的方式使用它时,您需要确保 sparql-gremlin
在 Gremlin 服务器的类路径中。换句话说,您正在发送要在服务器上执行的 g = traversal(SparqlTraversalSource).withGraph(graph)
的 Gremlin 字符串,如果 sparql-gremlin
不在其类路径中,服务器对 SparqlTraversalSource
一无所知。
要通过 Gremlin 控制台和 :remote
(即发送脚本)使其正常工作,我会尝试以下操作:
- 在 Gremlin 服务器(即 Janus 服务器)的类路径中获取
sparql-gremlin
。您可以使用bin/gremlin-server.sh install org.apache.tinkerpop sparql-gremlin 3.4.12
(或您使用的任何版本) 来做到最好
- 使用在服务器 YAML 文件中为 JanusGraph 配置的
graph
启动服务器 - 使用
:remote
连接 Gremlin 控制台,就像您在示例中所做的那样 - 通过发送
SparqlTraversalSource
的脚本来测试 Gremlin 服务器是否接收到包,该脚本应该 return 类名。 - 如果前面的步骤有效,您应该能够做到:
traversal(SparqlTraversalSource).withGraph(graph).sparql("SELECT ?....")
如果一切正常,那么下一步可能是在已经使用 SparqlTraversalSource
设置的 Gremlin 服务器初始化脚本中配置一个特殊的遍历源,以便您可以从脚本中引用它直接。