谁能提供一些示例代码或提示,以介绍如何将1MB CSV节点和1MB CSV边导入到在Cassandra上运行的Titan图形数据库中?
我有一些通过Gremlin导入的CSV小文件,但这似乎不适用于大文件。
我已经看到Faunus可以做到这一点,但我想避免花几天的时间进行设置。
看起来BatchGraph可能是可行的方法(https://github.com/tinkerpop/blueprints/wiki/Batch-Implementation),但是示例似乎并不完整。
在https://groups.google.com/forum/#!topic/aureliusgraphs/ew9PJVxa8Xw回答了我的问题:
1)gremlin脚本适合导入1mb(Stephen Mallette)
2)BatchGraph代码(Daniel Kuppitz)
先决条件:
echo "alice,32" > /tmp/vertices.csv
echo "bob,33" >> /tmp/vertices.csv
echo "alice,knows,bob" > /tmp/edges.csv
在Gremlin REPL中:
config = new BaseConfiguration()
config.setProperty("storage.backend", "inmemory")
g = TitanFactory.open(config)
bg = new BatchGraph(g, VertexIDType.STRING, 1000)
new File("/tmp/vertices.csv").each({ line ->
(username, age) = line.split(",")
user = bg.addVertex("user::" + username)
ElementHelper.setProperties(user, ["username":username,"age":age.toInteger()])
})
new File("/tmp/edges.csv").each({ line ->
(source, label, target) = line.split(",")
v1 = bg.getVertex("user::" + source)
v2 = bg.getVertex("user::" + target)
bg.addEdge(null, v1, v2, label)
})
bg.commit()
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句