负载BlogCatalog3数据通过的gremlin

TITAN分贝如何从(3 csv文件:http://socialcomputing.asu.edu/datasets/BlogCatalog3)数据加载到钛分贝。 我安装泰坦1.0版本只使用默认配置。负载BlogCatalog3数据通过的gremlin

回答:

我这样的代码:

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的数据。

以上是 负载BlogCatalog3数据通过的gremlin 的全部内容, 来源链接: utcz.com/qa/261198.html

回到顶部