【发布时间】:2021-02-12 13:18:14
【问题描述】:
目前我正在尝试通过gremlinpython 以编程方式从 igraph 导入一个大图。我对 gremlin 和我可能使用它的端点相当陌生。我目前面临的问题是节点/边中的属性可以有多种类型。 (例如:-> Bool 或 None 类型 | Int、Long 等。)
在将其导入此gremlin-server 时,我没有注意到任何错误(这是否称为 Apache TinkerGraph-Server?我应该如何称呼它?)。看来相同属性的类型可以是任意的。
但是,当使用 JanusGraph 时,我收到多个错误:
gremlin_python.driver.protocol.GremlinServerError: 500: Value [XXX] is not an instance of the expected data type for property key [YYY] and cannot be converted. Expected: class <SomeClass>, found: class <SomeOtherClass>
例如执行:
conn = DriverRemoteConnection("ws://localhost:8182/gremlin", "g")
remote_graph = traversal().withRemote(conn)
remote_graph.addV().property("test", 10000).next()
remote_graph.addV().property("test", 100000000000000000000000).next() # <- Causes an error on JanusGraph
我可以将一些属性转换为其他数据类型(Bool/None-Type-> -1,0,1),所以我可以避免这个错误。但我不确定我应该如何处理上面提供的示例。有没有办法显式设置属性的类型(至少对于数字类型),以便服务器知道存储它,例如作为 Long/BigInt 而不是 Int?尤其是在 python3 中,long(/bigint) 和 int 之间没有区别了。
那么具体来说有没有类似以下的内容?: 例如。执行:
remote_graph.addV().property("test", 10000).asLong().next()
remote_graph.addV().property("test", 10000, <Type: Long>).next()
【问题讨论】:
标签: gremlin janusgraph gremlinpython