是否可以从字节码生成gremlin脚本?
我正在开发一个POC,我需要通过Gremlin API查询图形Azure CosmosDB数据库。
目前,Azure CosmosDB不支持字节码。 Azure开发团队有started working on this但到目前为止还没有发布发布时间表。
我想准备一些工作代码,在将来可以获得字节码支持时,需要进行最少的重构。
基于Apache TinkerPop docs,有两种方式提交Gremlin查询:字节码和脚本
# script
client = Client('ws://localhost:8182/gremlin', 'g')
list = client.submit("g.V().has('person','name',name).out('knows')",{'name': 'marko'}).all()
# bytecode
g = traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
list = g.V().has("person","name","marko").out("knows").toList()
“字节码方式”对我来说似乎更有效(语法检查,IDE intellisens等)而且我对创建DSL(领域特定语言)感兴趣。
是否可以使用流畅的api并将其序列化为字符串,方式类似于:
client = Client('ws://localhost:8182/gremlin', 'g')
g = traversal()
q = g.V().has("person","name","marko").out("knows").toString()
list = client.submit(q).all()
我使用的是python 3.5和gremlinpython 3.4.0