Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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/8/xslt/3.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
Neo4J:用户定义的过程不喜欢定期提交?_Neo4j_Cypher - Fatal编程技术网

Neo4J:用户定义的过程不喜欢定期提交?

Neo4J:用户定义的过程不喜欢定期提交?,neo4j,cypher,Neo4j,Cypher,我试图开发一个Neo4J过程,从数据库导入节点,将其转换为CSV并将其加载到Neo4J中 我一直被以下问题困扰着:将过程作为单元测试运行很好。但是,当我尝试在Neo4J Desktop中运行该过程时,我始终遇到以下异常: org.neo4j.graphdb.QueryExecutionException: Executing stream that use periodic commit in an open transaction is not possible. at org

我试图开发一个Neo4J过程,从数据库导入节点,将其转换为CSV并将其加载到Neo4J中

我一直被以下问题困扰着:将过程作为单元测试运行很好。但是,当我尝试在Neo4J Desktop中运行该过程时,我始终遇到以下异常:

org.neo4j.graphdb.QueryExecutionException: Executing stream that use periodic commit in an open transaction is not possible.
        at org.neo4j.kernel.impl.query.QueryExecutionKernelException.asUserException(QueryExecutionKernelException.java:35)
        at org.neo4j.kernel.impl.proc.ProcedureGDBFacadeSPI.executeQuery(ProcedureGDBFacadeSPI.java:147)
        ....
当我调用
db.execute(..)
在我的
GraphDatabaseService
db上执行时,就会发生这种情况

确切的查询如下所示:

USING PERIODIC COMMIT 1000 
LOAD CSV WITH HEADERS FROM "file:/nodes_Class.txt" AS cl 
MERGE (n:Class { iri: cl.iri})
try (final Transaction tx = db.beginTx()) {
    db.execute( "USING PERIODIC COMMIT ..." );
    tx.success();
}

如果我在Neo4J Desktop中单独运行完全相同的查询,则导入所有节点时不会出现问题。现在我读到了定期提交。用一种愚蠢的方式问它:我如何告诉我的过程它被允许执行定期提交?

您正在尝试创建一个插件过程,它需要(非螺栓)。但这是为的,这是完全不同的(是的,这可能有点混乱)

使用JavaAPI(适用于插件),必须在事务外部调用“使用定期提交”子句

因此,不要像这样在事务中执行密码:

USING PERIODIC COMMIT 1000 
LOAD CSV WITH HEADERS FROM "file:/nodes_Class.txt" AS cl 
MERGE (n:Class { iri: cl.iri})
try (final Transaction tx = db.beginTx()) {
    db.execute( "USING PERIODIC COMMIT ..." );
    tx.success();
}
只需在事务之外执行它:

db.execute( "USING PERIODIC COMMIT ..." );

我替换了我的答案,因为我最初误读了你的问题。很高兴知道,谢谢:)现在你的答案解释了问题,但没有解决它:到目前为止,我没有将定期提交作为事务的一部分使用;现在,至少我知道了当我作为单元测试的一部分执行程序时,它为什么会工作。然而,这个过程应该可以作为Neo4J桌面的一部分使用,据我所知,Neo4J桌面通过bolt连接到数据库;那么,您知道我可以一般地进行定期提交的一种方法吗,即在一个有时涉及通过bolt(Neo4J桌面)连接,有时不涉及(cypher控制台)连接的设置中?非常感谢您的帮助。@matentzn您曾经解决过这个问题吗,我在尝试使用周期函数时遇到了完全相同的问题COMMIT@K.Haydock不幸的是没有。我记不清了,但我想我已经用一个可怕的“通过csv”解决方案替换了整个代码,使用GraphDatabaseApi。类似于“``String cypher=“USING PERIODIC COMMIT 5000\n”+”从\“file:/“+fn+”\”加载带有头的CSV,作为cl\n“+”合并(n:Entity{iri:cl.iri})集n+=…”;final Future cf=exService.submit(()->{dbapi.execute(cypher);返回“Finished:”+filename;});System.out.println(cf.get());`不知道为什么,太久以前了。