我想将子图导出到json文件中,然后导入其他图形。我试了如下:
gremlin> subGraph = g.V().has("name","john").outE("has").subgraph("subgraph").cap("subgraph").next()
==>tinkergraph[vertices:6 edges:5]现在我有了子图对象,然后我使用graphson将这个子图对象直接写入json文件,如下所示:
subGraph.io(GraphSONIo.build()).writeGraph("/tmp/subgraph.json")但是我遇到了这样的错误:
(was java.lang.IllegalStateException) (through reference chain: com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"])有什么问题??
发布于 2017-02-21 12:28:38
我认为问题在于,您有一个TinkerGraph作为您的子图,但是该子图包含一个泰坦标识符,GraphSON不知道如何本机处理这些标识符。您需要向GraphSON提供泰坦序列化程序,以便它知道如何处理RelationIdentifier。您没有说明您使用的是什么版本的土卫六,但我认为无论版本如何,这种方法都是有效的:
mapper = GraphSONMapper.build().
addCustomModule(TitanGraphSONModule.getInstance()).
create()
writer = GraphSONWriter.build().mapper(mapper).create()
os = new FileOutputStream("/tmp/subgraph.json")
writer.writeGraph(os, subgraph)对于JanusGraph来说,更现代的方法是:
sg.io('/tmp/sample.json').
by(IO.registry, org.janusgraph.graphdb.tinkerpop.io.graphson.JanusGraphSONModuleV2d0.getInstance()).
write().iterate()https://stackoverflow.com/questions/42364774
复制相似问题