由于内存错误,Windows Neo4j无法创建具有25000个节点的图形

时间:2014-08-04 20:27:58

标签: neo4j

我正在尝试在具有350,000个节点的Windows机器上创建图形 - 遗憾的是我甚至无法创建具有25,000个节点的图形。 500节点工作。 25,000运行20分钟,然后发出Java堆错误。

下面是cypher脚本,在csv文件中我控制行数(想做350K)。我得到的错误是Java堆 - 我尝试将内存配置增加到1024,没有帮助,它不会让我增加到2048.

LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
MERGE (f:F { name: csvLine.f })
MERGE (s:S { name: csvLine.s })
MERGE (t:T { name: csvLine.t })
MERGE (region:R { name: csvLine.r })
CREATE (d:D { name: csvLine.name})
CREATE (d)-[:BELONGS_TO]->(f)
CREATE (f)-[:BELONGS_TO]->(r)
CREATE (d)-[:LOCATED_IN]->(s)
CREATE (d)-[:LOCATED_IN]->(t)
CREATE (s)-[:PINGS{c: toInt(csvLine.c)}]->(t)

1 个答案:

答案 0 :(得分:1)

不幸的是你必须做三件事

  1. 更新至Neo4j 2.1.3

  2. 创建必要的索引

  3. 将您的陈述简化为多个简单陈述。 原因是Cypher(当你匹配+创建数据时)必须提前提取所有合并/匹配状态,以免受到后来创建的数据的影响。


  4.  USING PERIODIC COMMIT 1000
     LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
     MERGE (f:F { name: csvLine.f });
    
    
    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    MERGE (s:S { name: csvLine.s });
    
    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    MERGE (t:T { name: csvLine.t });
    
    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    MERGE (region:R { name: csvLine.r });
    
    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    CREATE (d:D { name: csvLine.name});
    
    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    MATCH (f:F { name: csvLine.f })
    MATCH (s:S { name: csvLine.s })
    MATCH (t:T { name: csvLine.t })
    MATCH (region:R { name: csvLine.r })
    MATCH (d:D { name: csvLine.name})
    CREATE (d)-[:BELONGS_TO]->(f)
    CREATE (f)-[:BELONGS_TO]->(r)
    CREATE (d)-[:LOCATED_IN]->(s)
    CREATE (d)-[:LOCATED_IN]->(t)
    CREATE (s)-[:PINGS{c: toInt(csvLine.c)}]->(t);
    

    对于第一个,如果你只导入一个文件(这些会更快),你也可以使用这个结构

    USING PERIODIC COMMIT 1000
    LOAD CSV WITH HEADERS FROM "file:c:...my file.csv" AS csvLine
    WITH distinct csvLine.f as csv_f
    CREATE (f:F { name: csv_f });