我想传递需要迭代的列表,并从中创建节点和关系。
我现在使用的是Apoc.periodic.iterate,因为以前我尝试过使用unwind进行操作,由于并行执行导致死锁。
帮我修复当前代码部分。
我正在分块处理超过900k数据。我将从kafka主题中阅读。
当前代码部分:
ToString
上一个代码部分:
@Query("CALL apoc.periodic.iterate("+"\""
+ " UNWIND $items as item return item\" ,"
+ "\"MERGE (src:Item {name: item.name}) "
+ " ON CREATE SET src.name = item.name, "
+ " src.updateDate = {processDate} "
+ "MERGE (dest:ItemDet {upc: item.upc}) "
+ " ON CREATE SET dest.upc = item.upc, "
+ " dest.creationDate = {processDate} " )\",
{batchSize:1000, parallel:false,iterateList:true,params:{items:{items}}})")
Result mergeItems(@Param("items") List<?> items,
@Param("processDate") String processDate);
错误日志
@Query("UNWIND {items} as item MERGE(src:Item {name: item.name}) "
+ " ON CREATE SET src.name = item.name, "
+ " src.updateDate = {processDate} "
+ "MERGE (dest:ItemDet {upc: item.upc}) "
+ " ON CREATE SET dest.upc = item.upc, "
+ " dest.creationDate = {processDate} ")
Result mergeItems(@Param("items") List<?> items,
@Param("processDate") String processDate);
答案 0 :(得分:0)
1) Its due to syntax error .I have found the fix.
@Query("CALL apoc.periodic.iterate("+"\""
+ " UNWIND $items as item return item\" ,"
+ "\"MERGE (src:Item {name: item.name}) "
+ " ON CREATE SET src.name = item.name, "
+ " src.updateDate = {processDate} "
+ "MERGE (dest:ItemDet {upc: item.upc}) "
+ " ON CREATE SET dest.upc = item.upc, "
+ " dest.creationDate = {processDate} "\",
{batchSize:1000, parallel:false,iterateList:true,params:{items:{items},{processDate:{processDate}}}})")
Result mergeItems(@Param("items") List<?> items,
@Param("processDate") String processDate);
</CODE>