PeriodicExtended { @Deprecated @Procedure(mode = Mode.WRITE) @Description("apoc.periodic.rock_n_roll('some cypher for iteration', 'some cypher as action on each iteration', 10000) YIELD batches, total - run the action statement in batches over the iterator statement's results in a separate thread. Returns number of batches and total processed rows") public Stream<BatchAndTotalResult> rock_n_roll( @Name("cypherIterate") String cypherIterate, @Name("cypherAction") String cypherAction, @Name("batchSize") long batchSize) { Map<String, String> fieldStatement = Util.map( "cypherIterate", cypherIterate, "cypherAction", cypherAction); validateQueries(fieldStatement); log.info("starting batched operation using iteration `%s` in separate thread", cypherIterate); try (Result result = tx.execute(cypherIterate)) { return iterateAndExecuteBatchedInSeparateThread((int)batchSize, false, false, 0, result, (tx, p) -> tx.execute(cypherAction, p), 50, -1); } }  @Procedure(mode = Mode.WRITE) @Deprecated @Description("apoc.periodic.rock_n_roll_while('some cypher for knowing when to stop', 'some cypher for iteration', 'some cypher as action on each iteration', 10000) YIELD batches, total - run the action statement in batches over the iterator statement's results in a separate thread. Returns number of batches and total processed rows") Stream<LoopingBatchAndTotalResult> rock_n_roll_while(
            @Name("cypherLoop") String cypherLoop,
            @Name("cypherIterate") String cypherIterate,
            @Name("cypherAction") String cypherAction,
            @Name("batchSize") long batchSize); @Deprecated @Procedure(mode = Mode.WRITE) @Description("apoc.periodic.rock_n_roll('some cypher for iteration', 'some cypher as action on each iteration', 10000) YIELD batches, total - run the action statement in batches over the iterator statement's results in a separate thread. Returns number of batches and total processed rows") Stream<BatchAndTotalResult> rock_n_roll(
            @Name("cypherIterate") String cypherIterate,
            @Name("cypherAction") String cypherAction,
            @Name("batchSize") long batchSize); @Context public GraphDatabaseService db; @Context public TerminationGuard terminationGuard; @Context public Log log; @Context public Pools pools; @Context public Transaction tx; }
@Test public void testRock_n_roll() throws Exception { db.executeTransactionally("UNWIND range(1,100) AS x CREATE (:Person{name:'Person_'+x})"); testResult(db, "CALL apoc.periodic.rock_n_roll('match (p:Person) return p', 'WITH $p as p SET p.lastname =p.name REMOVE p.name', 10)", result -> { Map<String, Object> row = Iterators.single(result); assertEquals(10L, row.get("batches")); assertEquals(100L, row.get("total")); }); testCall(db, "MATCH (p:Person) where p.lastname is not null return count(p) as count", row -> assertEquals(100L, row.get("count")) ); }