以字符串的形式获取Gremlin查询,并在Java中执行它,而无需将其提交给GremlinServer [英] Get Gremlin query as a String and execute it in java without submitting it to the GremlinServer
问题描述
我有一个String格式的Gremlin查询(例如"g.V()").我想执行此字符串而不将其提交给GremlinServer.
I have a Gremlin query in the String format (for example "g.V()"). I want to execute this String without submitting it to the GremlinServer.
我使用以下依赖项:
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.3.1</version>
</dependency>
有什么办法吗?
推荐答案
您可以直接在 GremlinExecutor (它只是将字符串传递给GremlinGroovyScriptEngine
,但还具有一些其他功能).只需将Gremlin字符串传递给适当的eval()
方法,然后从该脚本评估中获取结果.基本上,这就是Gremlin Server在内部执行的操作.
You can execute Gremlin string directly in GremlinGroovyScriptEngine or through the GremlinExecutor (which just passes the string to the GremlinGroovyScriptEngine
but has some additional features to it). Simple pass the Gremlin string to the appropriate eval()
method and get back a result from that script evaluation. That's basically what Gremlin Server does internally.
您可能需要gremlin-groovy
依赖而不是gremlin-driver
.
You will likely need the gremlin-groovy
dependency rather than gremlin-driver
.
这篇关于以字符串的形式获取Gremlin查询,并在Java中执行它,而无需将其提交给GremlinServer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!