neo4j shell - 从.csv创建边缘

时间:2015-05-11 17:31:45

标签: csv neo4j

我使用逗号分隔值文件在Neo4j数据库中创建节点和边。创建节点的命令运行没有问题。创建边缘的尝试失败,并显示以下错误:

  

线程“GC-Monitor”中的异常java.lang.OutOfMemoryError:GC   超出限额

     

异常:抛出java.lang.OutOfMemoryError   线程“GC-Monitor”中的UncaughtExceptionHandler

此外,在命令的输出中有这样的:

neo4j-sh (?)$ using periodic commit 400 load csv with headers from 'file://localhost/tmp/vm2set3.csv' as line match (u:VM {id: line.vm_id}),(s:VNIC  {id: line.set3_id}) create (u)-[:VNIC]->(s);
SystemException: Kernel has encountered some problem, please perform neccesary action (tx recovery/restart)
neo4j-sh (?)$
SystemException: Kernel has encountered some problem, please perform neccesary action (tx recovery/restart)
neo4j-sh (?)$ using periodic commit 400 load csv with headers from 'file://localhost/tmp/unix2switch.csv' as line match (u:UNIX {id: line.intf_id}),(s:switch  {id: line.set2a_id}) create (u)-[:cable]->(s);
SystemException: Kernel has encountered some problem, please perform neccesary action (tx recovery/restart)
neo4j-sh (?)$

我的shell脚本是:

cat /home/ES2Neo/2.1/neo4j_commands.cql | /export/neo4j-community-2.1.4/bin/neo4j-shell -path /export/neo4j-community-2.1.4/data/graph.db > /tmp/na.out

命令如下:

load csv WITH HEADERS from 'file://localhost/tmp/intf.csv' AS line CREATE (:UNIX {id: line.id, MAC: line.MAC ,BIA: line.BIA ,host: line.host,name: line.name});

表示节点,

using periodic commit 400 load csv with headers from 'file://localhost/tmp/unix2switch.csv' as line match (u:UNIX {id: line.intf_id}),(s:switch  {id: line.set2a_id}) create (u)-[:cable]->(s);

为边缘。

csv输入文件如下所示:

"intf_id","set2a_id"
"100321","6724919"
"125850","6717849"
"158249","6081895"
"51329","5565380"
"57248","6680663"
"235196","6094139"
"229242","4800249"
"225630","6661742"
"183281","4760022"

我做错了吗?我需要检查Neo4j配置中的某些内容吗?感谢。

1 个答案:

答案 0 :(得分:2)

问题是您的内存不足以将数据加载到数据库中。

查看this blog post,其中详细介绍了如何成功加载CSV数据。

特别是,您应该注意博客文章的关键部分。

  

您拥有的内存越多,导入数据的速度就越快。

     

因此,请务必编辑conf / neo4j-wrapper.conf并设置:

# Uncomment these lines to set specific initial and maximum
# heap size in MB.
wrapper.java.initmemory=4096
wrapper.java.maxmemory=4096
  

在conf / neo4j.properties中设置:

# Default values for the low-level graph engine
neostore.nodestore.db.mapped_memory=50M
neostore.relationshipstore.db.mapped_memory=500M
neostore.propertystore.db.mapped_memory=100M
neostore.propertystore.db.strings.mapped_memory=100M
neostore.propertystore.db.arrays.mapped_memory=0M