Optimization

This commit is contained in:
Andrea Cavalli 2021-09-09 23:27:39 +02:00
parent f157e67818
commit c47f45076a
3 changed files with 10 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import static it.cavallium.dbengine.lucene.searcher.PaginationInfo.MAX_SINGLE_SE
import it.cavallium.dbengine.database.LLKeyScore;
import it.cavallium.dbengine.lucene.LuceneUtils;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.ScoreDoc;
@ -93,8 +94,9 @@ public class SimpleLuceneLocalSearcher implements LuceneLocalSearcher {
s -> {}
)
.subscribeOn(scheduler)
.flatMapSequential(topFieldDoc -> LuceneUtils.convertHits(Flux.fromArray(topFieldDoc.scoreDocs),
IndexSearchers.unsharded(indexSearcher), keyFieldName, scheduler, true), 2)
.flatMapIterable(topDocs -> Arrays.asList(topDocs.scoreDocs))
.transform(topFieldDocFlux -> LuceneUtils.convertHits(topFieldDocFlux,
IndexSearchers.unsharded(indexSearcher), keyFieldName, scheduler, true))
);
}

View File

@ -7,6 +7,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.stream.Collectors;
@ -127,8 +128,9 @@ class UnscoredPagedLuceneShardSearcher implements LuceneShardSearcher {
}
)
.subscribeOn(scheduler)
.flatMapSequential(topFieldDoc -> LuceneUtils.convertHits(Flux.fromArray(topFieldDoc.scoreDocs),
indexSearchers, keyFieldName, scheduler, false), 2)
.flatMapIterable(topDocs -> Arrays.asList(topDocs.scoreDocs))
.transform(scoreDocsFlux -> LuceneUtils.convertHits(scoreDocsFlux,
indexSearchers, keyFieldName, scheduler, false))
.transform(flux -> {
if (paginationInfo.forceSinglePage()
|| paginationInfo.totalLimit() - paginationInfo.firstPageLimit() <= 0) {

View File

@ -164,7 +164,8 @@ public class UnscoredUnsortedContinuousLuceneMultiSearcher implements LuceneMult
}
return null;
}).thenMany(scoreDocsSink.asFlux());
var resultsFlux = LuceneUtils.convertHits(scoreDocsFlux, indexSearchers, keyFieldName, scheduler, false);
var resultsFlux = LuceneUtils
.convertHits(scoreDocsFlux, indexSearchers, keyFieldName, scheduler, false);
return new LuceneSearchResult(TotalHitsCount.of(0, false), resultsFlux, release);
})