【发布时间】:2020-04-10 04:29:41
【问题描述】:
我将g:Vertex 的example vertex GraphSON 放在一个文件中:
$ cat vertex.json
{ "@type" : "g:Vertex", "@value" : { "id" : { "@type" : "g:Int32", "@value" : 1 }, "label" : "person", "properties" : { "name" : [ { "@type" : "g:VertexProperty", "@value" : { "id" : { "@type" : "g:Int64", "@value" : 0 }, "value" : "marko", "label" : "name" } } ], "location" : [ { "@type" : "g:VertexProperty", "@value" : { "id" : { "@type" : "g:Int64", "@value" : 6 }, "value" : "san diego", "label" : "location", "properties" : { "startTime" : { "@type" : "g:Int32", "@value" : 1997 }, "endTime" : { "@type" : "g:Int32", "@value" : 2001 } } } }, { "@type" : "g:VertexProperty", "@value" : { "id" : { "@type" : "g:Int64", "@value" : 7 }, "value" : "santa cruz", "label" : "location", "properties" : { "startTime" : { "@type" : "g:Int32", "@value" : 2001 }, "endTime" : { "@type" : "g:Int32", "@value" : 2004 } } } }, { "@type" : "g:VertexProperty", "@value" : { "id" : { "@type" : "g:Int64", "@value" : 8 }, "value" : "brussels", "label" : "location", "properties" : { "startTime" : { "@type" : "g:Int32", "@value" : 2004 }, "endTime" : { "@type" : "g:Int32", "@value" : 2005 } } } }, { "@type" : "g:VertexProperty", "@value" : { "id" : { "@type" : "g:Int64", "@value" : 9 }, "value" : "santa fe", "label" : "location", "properties" : { "startTime" : { "@type" : "g:Int32", "@value" : 2005 } } } } ] } } }
尝试将其读入 Python Gremlin Server:
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
g = traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
g.io("/home/ubuntu/vertex.json").read().iterate()
产生错误:
GremlinServerError: 500: org.apache.tinkerpop.shaded.jackson.databind.JsonMappingException: 无法按要求反序列化 JSON 值。嵌套异常: java.lang.InstantiationException:无法反序列化值 JSON ('g:Vertex') 中包含的检测到的类型到类型 在对象映射器的参数中指定(接口 java.util.Map)。 这些类型是不兼容的。在 [来源:(ByteArrayInputStream); 行:1,列:36]
我尝试使用DriverRemoteConnection 的graphson_reader 和message_serializer 参数来指定GraphSONSerializersV3d0,但我无法克服该错误。
如何将上面的示例顶点 GraphSON 读入 Python 的 Gremlin 服务器中的图形?
【问题讨论】:
标签: python json gremlin gremlin-server graphson