Don't parallelize here

This commit is contained in:
Andrea Cavalli 2021-09-10 01:13:39 +02:00
parent 36dde3bb5a
commit 9e09574517
2 changed files with 10 additions and 12 deletions

View File

@ -371,17 +371,13 @@ public class LuceneUtils {
return hits.transform(hitsFlux -> {
if (preserveOrder) {
return hitsFlux.flatMapSequential(hit -> Mono
.fromCallable(() -> mapHitBlocking(hit, indexSearchers, keyFieldName))
.subscribeOn(scheduler),
3
);
return hitsFlux
.publishOn(scheduler)
.mapNotNull(hit -> mapHitBlocking(hit, indexSearchers, keyFieldName));
} else {
return hitsFlux.flatMap(hit -> Mono
.fromCallable(() -> mapHitBlocking(hit, indexSearchers, keyFieldName))
.subscribeOn(scheduler),
3
);
return hitsFlux
.publishOn(scheduler)
.mapNotNull(hit -> mapHitBlocking(hit, indexSearchers, keyFieldName));
}
});
}

View File

@ -8,6 +8,7 @@ import it.cavallium.dbengine.lucene.LuceneUtils;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
@ -150,8 +151,9 @@ class ScoredSimpleLuceneShardSearcher implements LuceneShardSearcher {
return flux;
}
})
.flatMapSequential(topFieldDoc -> LuceneUtils.convertHits(Flux.fromArray(topFieldDoc.scoreDocs),
indexSearchers, keyFieldName, collectorScheduler, true), 3);
.flatMapIterable(topFieldDoc -> Arrays.asList(topFieldDoc.scoreDocs))
.transform(scoreDocs -> LuceneUtils.convertHits(scoreDocs,
indexSearchers, keyFieldName, collectorScheduler, true));
return new LuceneSearchResult(LuceneUtils.convertTotalHitsCount(result.totalHits),
firstPageHits