Gremlin Through java reading external JSON vertex and add to existing open graph gives Invalid vertex provided 异常?
Gremlin Through java reading external JSON vertex and add to existing open graph gives Invalid vertex provided exception?
我正在尝试读取外部 JSON 顶点并将其添加到退出打开的泰坦图中。如下:
gremlin> newVertex = graph.io(GraphSONIo.build()).reader().create().readVertex(new FileInputStream("/tmp/sample_vertex.json"),null);
gremlin> v[42092]
gremlin> existingVertex = graph.V(4145).next();
gremlin> v[4145]
gremlin> existingVertex.addEdge("has",newVertex);
Invalid vertex provided: v[42092]
我已经使用 GraphSON.io 导出顶点,如下所示:
gremlin> graph.io(GraphSONIo.build()).writer().create().writeVertex(new FileInputStream("/tmp/sample_vertex.json"),g.V().next());
readVertex
的签名如下所示:
Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod)
如果您向 vertexAttachMethod
提供 null
,则不会尝试将顶点附加到您的图形,您只会得到一个未附加的 StarVertex
作为结果。请考虑以下方法:
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> start = graph.io(GraphSONIo.build()).reader().create().readVertex(new FileInputStream('v.json'), Attachable.Method.create(graph))
==>v[1]
gremlin> gremlin> g.V(start).as('start').
......1> addV().as('end').
......2> addE('has').from('start').to('end')
==>e[1][1-has->0]
我正在尝试读取外部 JSON 顶点并将其添加到退出打开的泰坦图中。如下:
gremlin> newVertex = graph.io(GraphSONIo.build()).reader().create().readVertex(new FileInputStream("/tmp/sample_vertex.json"),null);
gremlin> v[42092]
gremlin> existingVertex = graph.V(4145).next();
gremlin> v[4145]
gremlin> existingVertex.addEdge("has",newVertex);
Invalid vertex provided: v[42092]
我已经使用 GraphSON.io 导出顶点,如下所示:
gremlin> graph.io(GraphSONIo.build()).writer().create().writeVertex(new FileInputStream("/tmp/sample_vertex.json"),g.V().next());
readVertex
的签名如下所示:
Vertex readVertex(InputStream inputStream, Function<Attachable<Vertex>, Vertex> vertexAttachMethod)
如果您向 vertexAttachMethod
提供 null
,则不会尝试将顶点附加到您的图形,您只会得到一个未附加的 StarVertex
作为结果。请考虑以下方法:
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = graph.traversal()
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> start = graph.io(GraphSONIo.build()).reader().create().readVertex(new FileInputStream('v.json'), Attachable.Method.create(graph))
==>v[1]
gremlin> gremlin> g.V(start).as('start').
......1> addV().as('end').
......2> addE('has').from('start').to('end')
==>e[1][1-has->0]