0

我有一个包含 2200 万条 JSON 格式记录的大型数据集,我使用 apoc.periodic.iterate 和 apoc.mongodb 将其从 mongodb 数据库导入到 neo4j。导入 300 万条记录并占用 6g 内存后,与服务器的连接丢失,出现堆大小异常。我更改了配置文件并设置了堆和页面缓存,但没有生效,这是主要问题。顺便说一句,在浏览器中运行代码并使用 python 驱动程序具有相同的结果。尽管当我手动导入数据并以 250 万个限制导入它,然后在下一次查询执行中跳过它并导入下一个 250 万个批次时,它仍然有效。我实际上想用 python 驱动程序来做到这一点,但我无法模拟手动处理它的方式。

日志文件中有错误提示:协议握手期间发生致命错误...已建立的连接被主机中的软件中止...

4

1 回答 1

0

对于第一部分,请发送您的配置。对于简单的 pyhton 驱动程序,您可以使用带有地图参数列表的密码:

from neo4j import GraphDatabase

driver = GraphDatabase.driver("bolt://localhost:7687", auth=("neo4j",    "password"))

def add_friend(tx, name, friend_name):
    tx.run("MERGE (a:Person {name: $name}) "
           "MERGE (a)-[:KNOWS]->(friend:Person {name: $friend_name})", name=name, friend_name=friend_name)


def add_friend_list(tx, friend_list):
    tx.run("UNWIND $friend_list AS friend"
           "MERGE (a:Person {name: friend.name}) "
           "MERGE (a)-[:KNOWS]->(friend:Person {name: friend.friend_name})", friend_list)

def fetch_data_from_db():
     ...

with driver.session() as session:
    friends_list = fetch_data_from_db()
    for friend in friend_list:
        session.write_transaction(add_friend,                     friend["name"],friend["friend_name"])
    session.write_transaction(add_friend_list, friends_list)
于 2019-09-05T05:30:31.593 回答