java实现中的readVertices不从json读取顶点

时间:2017-03-08 05:38:51

标签: java json graph-databases titan gremlin

我使用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);
} }

0 个答案:

没有答案