(reverse-index) Fix parallel documents sorting bug

Bug was caused by parallel sorting capturing the iterator rather than the offsets to sort.
This commit is contained in:
Viktor Lofgren 2023-09-01 15:42:45 +02:00
parent d31d8ec5b0
commit 563e388a45

View File

@ -94,16 +94,15 @@ public class ReversePreindexDocuments {
ExecutorService sortingWorkers = Executors.newWorkStealingPool(Runtime.getRuntime().availableProcessors()); ExecutorService sortingWorkers = Executors.newWorkStealingPool(Runtime.getRuntime().availableProcessors());
while (iter.next()) { while (iter.next()) {
long iterStart = iter.startOffset;
long iterEnd = iter.endOffset;
if (iter.size() < 1024) { if (iter.size() < 1024) {
docsFileMap.quickSortN(RECORD_SIZE_LONGS, docsFileMap.quickSortN(RECORD_SIZE_LONGS, iterStart, iterEnd);
iter.startOffset,
iter.endOffset);
} }
else { else {
sortingWorkers.execute(() -> sortingWorkers.execute(() ->
docsFileMap.quickSortN(RECORD_SIZE_LONGS, docsFileMap.quickSortN(RECORD_SIZE_LONGS, iterStart, iterEnd));
iter.startOffset,
iter.endOffset));
} }
} }