Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Py2neo Neo4j批提交错误_Python_Batch File_Neo4j_Py2neo - Fatal编程技术网

Python Py2neo Neo4j批提交错误

Python Py2neo Neo4j批提交错误,python,batch-file,neo4j,py2neo,Python,Batch File,Neo4j,Py2neo,我有一个json文件,其中包含大约140万个节点的数据,我想为此构建一个Neo4j图形数据库。我尝试使用py2neo的批提交功能。我的代码如下: # the variable words is a list containing node names from py2neo import neo4j batch = neo4j.WriteBatch(graph_db) nodedict = {} # I decided to use a dictionary because I would be

我有一个json文件,其中包含大约140万个节点的数据,我想为此构建一个Neo4j图形数据库。我尝试使用py2neo的批提交功能。我的代码如下:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later
for i in words:
    nodedict[i] = batch.create({"name":i})
results = batch.submit()
Traceback (most recent call last):
  File "test.py", line 36, in <module>
    results = batch.submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2116, in submit
    for response in self._submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2085, in _submit
    for id_, request in enumerate(self.requests)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 427, in _send
    return self._client().send(request)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 364, in send
    return Response(request.graph_db, rs.status, request.uri, rs.getheader("Loc$
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 278, in __init__
    raise SystemError(body)
SystemError: None
显示的错误如下所示:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later
for i in words:
    nodedict[i] = batch.create({"name":i})
results = batch.submit()
Traceback (most recent call last):
  File "test.py", line 36, in <module>
    results = batch.submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2116, in submit
    for response in self._submit()
  File "/usr/lib/python2.6/site-packages/py2neo/neo4j.py", line 2085, in _submit
    for id_, request in enumerate(self.requests)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 427, in _send
    return self._client().send(request)
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 364, in send
    return Response(request.graph_db, rs.status, request.uri, rs.getheader("Loc$
  File "/usr/lib/python2.6/site-packages/py2neo/rest.py", line 278, in __init__
    raise SystemError(body)
SystemError: None
回溯(最近一次呼叫最后一次):
文件“test.py”,第36行,在
结果=批处理。提交()
文件“/usr/lib/python2.6/site packages/py2neo/neo4j.py”,第2116行,提交
请自行回复。_提交()
文件“/usr/lib/python2.6/site packages/py2neo/neo4j.py”,第2085行,在提交时
对于id,枚举中的请求(self.requests)
文件“/usr/lib/python2.6/site packages/py2neo/rest.py”,第427行,在
返回self.\u client().send(请求)
文件“/usr/lib/python2.6/site packages/py2neo/rest.py”,第364行,在send中
返回响应(request.graph_db、rs.status、request.uri、rs.getheader(“Loc$
文件“/usr/lib/python2.6/site packages/py2neo/rest.py”,第278行,在__
升起系统错误(正文)
系统错误:无

有人能告诉我这里到底发生了什么吗?这与批处理查询非常大这一事实有关系吗?如果有,可以做什么?提前感谢!:)

下面是我的答案(感谢这个问题:):

py2neo batch submit函数在可进行的查询方面有其自身的限制。虽然我无法获得上限的确切数量,但我尝试将每批查询的数量限制为5000。因此,我决定运行以下代码:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later

for index, i in enumerate(words):
    nodedict[i] = batch.create({"name":i})
    if index%5000 == 0:
        batch.submit()
        batch = neo4j.WriteBatch(graph_db) # As stated by Nigel below, I'm creating a new batch
batch.submit() #for the final batch

通过这种方式,我发送了批量请求(大小为5k的查询),并成功地创建了整个图形!

因此,我得出了以下结论(由于这个问题:):

py2neo batch submit函数在可进行的查询方面有其自身的限制。虽然我无法获得上限的确切数量,但我尝试将每批查询的数量限制为5000。因此,我决定运行以下代码:

# the variable words is a list containing node names
from py2neo import neo4j
batch = neo4j.WriteBatch(graph_db)
nodedict = {}
# I decided to use a dictionary because I would be creating relationships
# by referring to the dictionary entries later

for index, i in enumerate(words):
    nodedict[i] = batch.create({"name":i})
    if index%5000 == 0:
        batch.submit()
        batch = neo4j.WriteBatch(graph_db) # As stated by Nigel below, I'm creating a new batch
batch.submit() #for the final batch

通过这种方式,我发送了批量请求(大小为5k的查询)并且成功地创建了我的整个图表!

没有真正的方法来描述一个批次可以包含的作业数量的限制-它可以根据许多因素变化很大。一般来说,最好的办法是尝试为您的用例找到一个最佳大小,然后继续。看起来这就是您已经在做的事情ing:-)


就您的解决方案而言,我建议您做一个调整。批处理对象不是为重用而设计的,因此每次提交后,只需创建一个新的批处理,而不是清除批处理。在下一版本的py2neo中,多次提交批处理的功能将被删除。

没有真正的方法来描述作业数量限制一个批次可以包含哪些内容-它可以根据许多因素而变化很大。一般来说,最好的办法是进行实验,为您的用例找到一个最佳大小,然后继续。看起来这就是您已经在做的事情:-)


就您的解决方案而言,我建议您做一个调整。批处理对象不是为重用而设计的,因此每次提交后,只需创建一个新的批处理即可。在下一版本的py2neo中,多次提交批处理的功能将被删除。

在我开始通过gra使用批处理创建后,我也遇到了同样的问题上面的答案为我指明了正确的方向,我最终使用了这个问题的灵感片段

PS
py2neo==2.0.7

在我开始使用批处理创建via graph.create(*alist)之后,我遇到了同样的问题。上面的答案为我指明了正确的方向,我最终使用了这个问题的灵感片段

PS
py2neo==2.0.7

好吧,我想我在这里找到了答案:我想我会尝试将大批量查询分解为5k个查询中的较小部分,然后运行多个批量提交过程。希望它能工作:)好吧,我想我在这里找到了答案:我想我会尝试将大批量查询分解为5k个查询中的较小部分d然后运行多批提交过程。希望它能工作:)谢谢你的洞察力!不过我还有一个疑问。在下一步中,我想使用字典中存储的节点创建关系。但是,由于我提交批,它显示了一个值错误:找不到请求。你能提出一些建议吗?哦,我想我是这样想的d解决它。感谢这个问题:主要是因为您提到的问题中提出的问题,批将在下一版本的py2neo中成为一次性使用。提交后需要丢弃一个批,并在需要时创建另一个。感谢您的洞察力!不过我还有一个疑问。在下一步中,我想使用字典中存储的节点创建ate关系。但是,由于我正在提交批处理,它显示了一个值错误:找不到请求。您能提出一些建议吗?哦,我想我已经解决了。由于这个问题:主要是因为您引用的问题中提出的问题,批处理将在n中成为一次性使用py2neo的ext版本。提交后需要丢弃一个批,并在需要时创建另一个批。