简体   繁体   English

py2neo.WriteBatch如何工作?

[英]How does py2neo.WriteBatch work?

Here is the example given in py2neo document : 这是py2neo 文档中给出的示例:

batch = WriteBatch(graph_db)
batch.create(node(name="Alice"))
batch.create(node(name="Bob"))
batch.create(rel(0, "KNOWS", 1))
results = batch.submit()

How can the py2neo know the id of the created node 'Alice' and node 'Bob' is 0 and 1 so that it can create the relationship between the two nodes? py2neo如何知道创建的节点“ Alice”和节点“ Bob”的ID为0和1,以便它可以创建两个节点之间的关系? When I try a similar example, I find that the 0 and 1 are not the ids of nodes, so 0 means the first created node in the batch job? 当我尝试类似的示例时,我发现0和1不是节点的ID,所以0意味着批处理作业中第一个创建的节点? I read the source code and can not make sure about that. 我阅读了源代码,无法确定。

As you correctly assert, the 0 and 1 refer to the index numbers of the items within the batch job, not the absolute node IDs. 正确地说,0和1是指批处理作业中各项的索引号,而不是绝对节点ID。 This feature has been built in this way as it is a layer atop the REST batch interface which uses a similar notation: 此功能是通过这种方式构建的,因为它是使用类似符号的REST批处理接口之上的一层:

http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html#rest-api-refer-to-items-created-earlier-in-the-same-batch-job http://docs.neo4j.org/chunked/milestone/rest-api-batch-ops.html#rest-api-refer-to-items-created-earlier-in-the-same-batch-job

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM