我的問題得到回答在https://groups.google.com/forum/#!topic/aureliusgraphs/ew9PJVxa8Xw:
1)小鬼腳本是罰款1MB的進口(斯蒂芬Mallette)
2)BatchGraph代碼(丹尼爾Kuppitz)
Prerequisties:
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()
GremlinDocs也有一個簡單的例子來讀取文件。它很容易適應'BatchGraph':http://gremlindocs.com/#recipes/reading-from-a-file –
'BatchGraph'已被棄用,支持'BulkLoaderVertexProgram' – vinaykola