那时您要测量的是 lucene 索引的性能。
所以不是图形数据库操作。
有多种选择:
neo4j 导入
Neo4j 2.2.0-M03 附带 neo4j-import,这是一个可以快速、可扩展地将 10 亿节点 csv 导入 Neo4j 的工具。
并行批量导入器 API
这在 Neo4j 2.2 中是非常新的
我使用新的 ParallelBatchImporter 在 5 分钟 13 秒 (53G db) 内创建了一个仅包含 1.000.000.000 个节点的节点图。这使得它大约每秒 320 万个节点。
代码在这里:https://gist.github.com/jexp/0ff850ab2ce41c9ca5e6
批量插入器
您可以使用 Neo4j Batch-Inserter-API 创建该数据,而无需先创建 CSV。
在此处查看此示例,您必须采用该示例才能不读取 CSV,而是直接从 for 循环生成数据:http://jexp.de/blog/2014/10/flexible-neo4j-batch-import-with-groovy/
密码
如果您想使用 Cypher,我建议您在 JAVA_OPTS="-Xmx4G -Xms4G" bin/neo4j-shell -path billion.db 中运行类似的内容:
这是我在我的 macbook 上使用的 10M 和 100M 的代码和时间:
创建一个 1M 行的 csv 文件
ruby -e 'File.open("million.csv","w")
{ |f| (1..1000000).each{|i| f.write(i.to_s + "\n") } }'
在 MacBook Pro 上运行的实验
Cypher 执行是单线程的
估计大小 (15+42) 字节 * 节点数
// on my laptop
// 10M nodes, 1 property, 1 label each in 98228 ms (98s) taking 580 MB on disk
using periodic commit 10000
load csv from "file:million.csv" as row
//with row limit 5000
foreach (x in range(0,9) | create (:Person {id:toInt(row[0])*10+x}));
// on my laptop
// 100M nodes, 1 property, 1 label each in 1684411 ms (28 mins) taking 6 GB on disk
using periodic commit 1000
load csv from "file:million.csv" as row
foreach (x in range(0,99) | create (:Person {id:toInt(row[0])*100+x}));
// on my linux server
// 1B nodes, 1 property, 1 label each in 10588883 ms (176 min) taking 63 GB on disk
using periodic commit 1000
load csv from "file:million.csv" as row
foreach (x in range(0,999) | create (:Person {id:toInt(row[0])*100+x}));
创建索引
create index on :Person(id);
schema await
// took about 40 mins and increased the database size to 85 GB
那我可以跑了
match (:Person {id:8005300}) return count(*);
+----------+
| count(*) |
+----------+
| 1 |
+----------+
1 row
2 ms