我的代码是这样的:
graph = TinkerGraph.open() //g = graph.traversal() println "nodes.csv:" /*add nodes.csv to db, each node as int*/ new File('nodes.csv').eachLine {line -> (fromVertex) = line.split(",") //println fromVertex v1 = graph.addVertex("nodeid", fromVertex.toInteger()) } println "edges.csv:" graph.createIndex("edges", Vertex.class) g = graph.traversal() getOrCreate = {id -> g.V().has("nodeid", id.toInteger()).tryNext().orElseGet{g.addV().property("nodeid", id.toInteger()).next() } } /*traver edges.csv each line, add edge to db*/ new File("edges.csv").eachLine { if(!it.startsWith("#")){ (fromVertex, toVertex) = it.split(",").collect(getOrCreate) fromVertex.addEdge("friend", toVertex) } } println "group-edges.csv:" new File("group-edges.csv").eachLine { line -> (fromVertex, toVertex) = line.split(",") v = g.V().has("nodeid", fromVertex.toInteger()) //println v v.property("grpid",toVertex.toInteger()) } //g.tx().commit()
edges.csv:
1,2 1,3 4,5
组edges.csv:
1,1 2,1 3,1 4,2 5,2
nodes.csv:
1 2 3 4 5
的 问题是:当我关闭这个gremlin时,我无法查询保存到titan db的数据。 强>