Source:
<code>public ProcessorState<Page> process() { int batchSize; while (true) { if (selectedPositions.isEmpty()) { page = null; previouslyComputedResults = null; memoryContext.close(); verify(!lastComputeYielded); return finished(); } if (lastComputeYielded) { verify(lastComputeBatchSize > 0); batchSize = lastComputeBatchSize; lastComputeYielded = false; lastComputeBatchSize = 0; } else { batchSize = Math.min(selectedPositions.size(), projectBatchSize); } ProcessBatchResult result = processBatch(batchSize); if (result.isYieldFinish()) { lastComputeYielded = true; lastComputeBatchSize = batchSize; return yield(); } if (result.isPageTooLarge()) { verify(batchSize > 1); projectBatchSize = projectBatchSize / 2; continue; } verify(result.isSuccess()); Page page = result.getPage(); long pageSize = page.getSizeInBytes(); if (page.getPositionCount() > 1 && pageSize > MAX_PAGE_SIZE_IN_BYTES) { projectBatchSize = projectBatchSize / 2; } if (pageSize < MIN_PAGE_SIZE_IN_BYTES && projectBatchSize < MAX_BATCH_SIZE) { projectBatchSize = projectBatchSize * 2; } selectedPositions = selectedPositions.subRange(batchSize, selectedPositions.size()); for (int i = 0; i < previouslyComputedResults.length; i++) { if (previouslyComputedResults[i] != null && previouslyComputedResults[i].getPositionCount() > batchSize) { previouslyComputedResults[i] = previouslyComputedResults[i].getRegion(batchSize, previouslyComputedResults[i].getPositionCount() - batchSize); } else { previouslyComputedResults[i] = null; } } updateRetainedSize(); return ofResult(page); } <START> } <END></code><technical_language>local variable AtomicLong</technical_language>

Target:
public ProcessState<Page> process() { int batchSize; while (true) { if (selectedPositions.isEmpty()) { verify(!lastComputeYielded); return finished(); } if (lastComputeYielded) { verify(lastComputeBatchSize > 0); batchSize = lastComputeBatchSize; lastComputeYielded = false; lastComputeBatchSize = 0; } else { batchSize = Math.min(selectedPositions.size(), projectBatchSize); } ProcessBatchResult result = processBatch(batchSize); if (result.isYieldFinish()) { lastComputeYielded = true; lastComputeBatchSize = batchSize; updateRetainedSize(); return yield(); } if (result.isPageTooLarge()) { verify(batchSize > 1); projectBatchSize = projectBatchSize / 2; continue; } verify(result.isSuccess()); Page resultPage = result.getPage(); long pageSize = resultPage.getSizeInBytes(); if (resultPage.getPositionCount() > 1 && (pageSize > MAX_PAGE_SIZE_IN_BYTES || expressionProfiler.isExpressionExpensive())) { projectBatchSize = projectBatchSize / 2; } if (pageSize < MIN_PAGE_SIZE_IN_BYTES && projectBatchSize < MAX_BATCH_SIZE && !expressionProfiler.isExpressionExpensive()) { projectBatchSize = projectBatchSize * 2; } selectedPositions = selectedPositions.subRange(batchSize, selectedPositions.size()); for (int i = 0; i < previouslyComputedResults.length; i++) { if (previouslyComputedResults[i] != null && previouslyComputedResults[i].getPositionCount() > batchSize) { previouslyComputedResults[i] = previouslyComputedResults[i].getRegion(batchSize, previouslyComputedResults[i].getPositionCount() - batchSize); } else { previouslyComputedResults[i] = null; } } if (!selectedPositions.isEmpty()) { updateRetainedSize(); } else { page = null; for (int i = 0; i < previouslyComputedResults.length; i++) { previouslyComputedResults[i] = null; } memoryContext.setBytes(0); } return ofResult(resultPage); } }