Source:
<code>protected void processRecord(ComputationContext context, Record record) { try { BulkCommand command = BulkCodecs.getCommandCodec().decode(record.getData()); String commandId = command.getId(); <START> int bucketSize = command.getBucketSize(); <END> 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(); }</code><technical_language>bucket size command.getBucketSize if > 0 else BulkAdminService.getBucketSize(action)</technical_language>

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(); }