Get Gremlin query as a String and execute it in java without submitting it to the GremlinServer

社会主义新天地 提交于 2019-12-13 03:39:06

问题


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.

I use the below dependency:

<dependency>
    <groupId>org.apache.tinkerpop</groupId>
    <artifactId>gremlin-driver</artifactId>
    <version>3.3.1</version>
</dependency>

Is there any way?


回答1:


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.

You will likely need the gremlin-groovy dependency rather than gremlin-driver.



来源:https://stackoverflow.com/questions/50254378/get-gremlin-query-as-a-string-and-execute-it-in-java-without-submitting-it-to-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!