Cleanup utils

This commit is contained in:
Andrea Cavalli 2021-09-30 00:23:41 +02:00
parent dc14192dca
commit 9a6f195b63

View File

@ -189,14 +189,6 @@ public class LuceneUtils {
return tokenStream;
}
/**
*
* @return false if the result is not relevant
*/
public static boolean filterTopDoc(float score, Float minCompetitiveScore) {
return minCompetitiveScore == null || score >= minCompetitiveScore;
}
/**
* @throws NoSuchElementException when the key is not found
* @throws IOException when an error occurs when reading the document
@ -344,17 +336,6 @@ public class LuceneUtils {
}
}
@Nullable
public static FieldDoc getLastFieldDoc(ScoreDoc[] scoreDocs) {
if (scoreDocs == null) {
return null;
}
if (scoreDocs.length == 0) {
return null;
}
return (FieldDoc) scoreDocs[scoreDocs.length - 1];
}
@Nullable
public static ScoreDoc getLastScoreDoc(ScoreDoc[] scoreDocs) {
if (scoreDocs == null) {
@ -427,21 +408,6 @@ public class LuceneUtils {
}
}
/**
* Transform a flux of results to take elements while the minimum competitive score is valid
*/
public static Flux<LLKeyScore> filterTopDoc(Flux<LLKeyScore> flux, LocalQueryParams queryParams) {
if (queryParams.scoreMode().needsScores() && queryParams.minCompetitiveScore() != null) {
if (queryParams.sort() != null && queryParams.sort().needsScores()) {
return flux.takeWhile(entry -> LuceneUtils.filterTopDoc(entry.score(), queryParams.minCompetitiveScore()));
} else {
return flux.filter(entry -> LuceneUtils.filterTopDoc(entry.score(), queryParams.minCompetitiveScore()));
}
} else {
return flux;
}
}
public static TopDocs mergeTopDocs(Sort sort,
@Nullable Integer startN,
@Nullable Integer topN,
@ -521,16 +487,6 @@ public class LuceneUtils {
}
}
public static Scheduler newLuceneSearcherScheduler(boolean multi) {
return Schedulers.newBoundedElastic(
4,
Schedulers.DEFAULT_BOUNDED_ELASTIC_QUEUESIZE,
multi ? "lucene-searcher-multi" : "lucene-searcher-shard",
60,
true
);
}
public static Mono<LocalQueryParams> getMoreLikeThisQuery(
List<LLIndexSearcher> indexSearchers,
LocalQueryParams localQueryParams,