0
TITAN分貝如何從(3 csv文件:http://socialcomputing.asu.edu/datasets/BlogCatalog3)數據加載到鈦分貝。 我安裝泰坦1.0版本只使用默認配置。負載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的數據。
在一個側面說明,泰坦將不再保留,並作爲分叉JanusGraph:http://janusgraph.org/除非你真的有使用泰坦,我建議你改用劍鋒。 – jbmusso