Does SPARQL-Gremlin plugin support Janusgraph?

Viewed 143

I'm trying to test if janusgraph could be queried with sparql. So, I found one of plug-in 'SPARQL-Gremlin' could do that. (At least, the doc said it is working.) However, when I followed the doc https://tinkerpop.apache.org/docs/current/reference/#sparql-gremlin I found that if current storage is TinkGraph, then the sparql could be run successfully. However, if I change storage solution to the remote(janusgraph), then I got error message. So, is there anyone who have been succeed based on this plugin and 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)

'''
1 Answers

The comment form HadoopMarc is the likely lead to solving your problem. You need to be sure sparql-gremlin is on your classpath for Gremlin Server when using this the way that you are in Gremlin Console. In other words, you are sending the Gremlin string of g = traversal(SparqlTraversalSource).withGraph(graph) to be executed on the server and the server doesn't know anything about SparqlTraversalSource if sparql-gremlin is not in its classpath.

To get this working via Gremlin Console and :remote (i.e. sending scripts) I would do try the following:

  1. Get sparql-gremlin on your classpath for Gremlin Server (i.e. Janus Server). You can do that best with bin/gremlin-server.sh install org.apache.tinkerpop sparql-gremlin 3.4.12 (or whatever version you are using)
  2. Start the server with a graph configured for JanusGraph in the server YAML file
  3. Connect with Gremlin Console using :remote as you did in your example
  4. Test to see if Gremlin Server picked up the package by sending just submitting a script of SparqlTraversalSource which should return the classname.
  5. If the previous step worked you should be able to do: traversal(SparqlTraversalSource).withGraph(graph).sparql("SELECT ?....")

If you have that all working then a next step might be to configure a special traversal source in the Gremlin Server initialization script that is already setup with the SparqlTraversalSource so that you can just reference it from your scripts directly.

Related