Source:
protected void processRecord(ComputationContext context, Record record) { try { BulkCommand command = BulkCodecs.getCommandCodec().decode(record.getData()); String commandId = command.getId(); int bucketSize = command.getBucketSize(); if (bucketSize > scrollBatchSize) { log.warn(String.format("Bucket size: %d too big for action: %s, reduce to scroll size: %d", bucketSize, command.getAction(), scrollBatchSize)); bucketSize = scrollBatchSize; } updateStatusAsScrolling(context, commandId); LoginContext loginContext; try { loginContext = Framework.loginAsUser(command.getUsername()); try (CloseableCoreSession session = CoreInstance.openCoreSession(command.getRepository())) { ScrollResult<String> scroll = session.scroll(command.getQuery(), scrollBatchSize, scrollKeepAliveSeconds); long documentCount = 0; long bucketNumber = 1; while (scroll.hasResults()) { List<String> docIds = scroll.getResults(); documentIds.addAll(docIds); while (documentIds.size() >= bucketSize) { produceBucket(context, command.getAction(), commandId, bucketSize, bucketNumber++); } documentCount += docIds.size(); scroll = session.scroll(scroll.getScrollId()); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); } if (!documentIds.isEmpty()) { produceBucket(context, command.getAction(), commandId, bucketSize, bucketNumber++); } updateStatusAfterScroll(context, commandId, documentCount); } catch (IllegalArgumentException | QueryParseException | DocumentNotFoundException e) { log.error("Invalid query results in an empty document set: " + command.toString(), e); updateStatusAfterScroll(context, commandId, 0); } finally { loginContext.logout(); } } catch (LoginException e) { throw new NuxeoException(e); } } catch (NuxeoException e) { log.error("Discard invalid record: " + record, e); } context.askForCheckpoint(); }

Target:
protected void processRecord(ComputationContext context, Record record) { try { BulkCommand command = BulkCodecs.getCommandCodec().decode(record.getData()); String commandId = command.getId(); int bucketSize = command.getBucketSize() > 0 ? command.getBucketSize() : Framework.getService(BulkAdminService.class).getBucketSize(command.getAction()); if (bucketSize > scrollBatchSize) { log.warn(String.format("Bucket size: %d too big for action: %s, reduce to scroll size: %d", bucketSize, command.getAction(), scrollBatchSize)); bucketSize = scrollBatchSize; } updateStatusAsScrolling(context, commandId); LoginContext loginContext; try { loginContext = Framework.loginAsUser(command.getUsername()); try (CloseableCoreSession session = CoreInstance.openCoreSession(command.getRepository())) { ScrollResult<String> scroll = session.scroll(command.getQuery(), scrollBatchSize, scrollKeepAliveSeconds); long documentCount = 0; long bucketNumber = 1; while (scroll.hasResults()) { List<String> docIds = scroll.getResults(); documentIds.addAll(docIds); while (documentIds.size() >= bucketSize) { produceBucket(context, command.getAction(), commandId, bucketSize, bucketNumber++); } documentCount += docIds.size(); scroll = session.scroll(scroll.getScrollId()); TransactionHelper.commitOrRollbackTransaction(); TransactionHelper.startTransaction(); } if (!documentIds.isEmpty()) { produceBucket(context, command.getAction(), commandId, bucketSize, bucketNumber++); } updateStatusAfterScroll(context, commandId, documentCount); } catch (IllegalArgumentException | QueryParseException | DocumentNotFoundException e) { log.error("Invalid query results in an empty document set: " + command.toString(), e); updateStatusAfterScroll(context, commandId, 0); } finally { loginContext.logout(); } } catch (LoginException e) { throw new NuxeoException(e); } } catch (NuxeoException e) { log.error("Discard invalid record: " + record, e); } context.askForCheckpoint(); }