目前,我正在尝试通过gremlinpython以编程方式从graph导入一个大图形。我对gremlin和我可能使用它的端点比较陌生。我目前面临的问题是,节点/边中的属性可以有多种类型。(例如:或None-类型| ->、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()发布于 2021-02-16 21:43:37
Gremlin确实有一个用于确保Java Long的special class。您可以在给定适当导入的情况下执行long(10000),如:from gremlin_python.statics import long
https://stackoverflow.com/questions/66172572
复制相似问题