且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

适用于Azure CosmosDB的Gremlin Python SDK

更新时间:2023-02-14 08:53:20

如您所述,没有纯字节码支持此处关于使用Gremlin在CosmosDB中使用Python的故事不是很好.有一些机制可以将字节码转换为脚本表示形式,例如Java的 GroovyTranslator 和Javascript的 Translator .例如,在Javascript中,您可以执行以下操作:

Without pure bytecode support as you noted here the story for Python usage for CosmosDB with Gremlin is not so good. There are some mechanisms for translating bytecode to script representations like GroovyTranslator for Java and Translator for Javascript. For example, in Javascript you could do:

const script = new Translator('g').translate(g.V().out('created').getBytecode());

,然后将该脚本提交给CosmosDB(Java的示例是此处).虽然不怎么好,但是可以说比将Gremlin繁琐的字符串嵌入到您的代码中更好.不幸的是,目前在Python中不支持此功能.我已经在JIRA中创建了一个问题来对其进行跟踪( TINKERPOP-2366 -Python和 TINKERPOP-2367 -.NET),因为我已经看到了这个问题以合理的一致性以不同的形式出现.

and then submit that script to CosmosDB (example for Java is here). Not great but arguably better than embedding fat strings of Gremlin into your code. Unfortunately, there is no support for this functionality in Python at this time. I've created an issue in JIRA to track it (TINKERPOP-2366 - Python and TINKERPOP-2367 - .NET) as I've seen this question come up in different forms with reasonable consistency.