我使用writeVertices()
GraphSONWriter
方法将一些属于同一类别的顶点导出到一个json
文件。
现在我使用gremlin导入该文件:
gremlin> graph.io(GraphSONIo.build()).reader().create().readVertices(fileinputStream, Attachable.Method.create(graph), Attachable.Method.create(graph), Direction.BOTH);
这成功导入了所有顶点。 BUT
我在JAVA
中尝试了相同的查询但它没有给出任何错误,但顶点没有导入。?
public JsonNode importObjects()throws JsonProcessingException{
Map<String,Object> out = new HashMap<>();
try{
FileInputStream fileinputStream=new FileInputStream(new File("vertics.json"));
TitanGraph graph = getDataSource().getGraph();
Iterator<Vertex>vitr=graph.io(GraphSONIo.build()).reader().create().readVertices(fileinputStream, Attachable.Method.create(graph), Attachable.Method.create(graph) ,Direction.BOTH);
graph.tx().commit();
out.put("Success", "imported objects!");
return JsonHelper.convert(out);
}catch (Exception e) {
out.put("Error", e);
return JsonHelper.convert(out);
} }