Skip to content

Commit

Permalink
Lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret committed May 30, 2024
1 parent 0a27bb1 commit 2dc4e4d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@ public ActionRequestValidationException validate() {
}
}
if (source.rescores() != null) {
for (@SuppressWarnings("rawtypes") RescorerBuilder rescoreBuilder : source.rescores()) {
for (@SuppressWarnings("rawtypes")
RescorerBuilder rescoreBuilder : source.rescores()) {
validationException = rescoreBuilder.validate(this, validationException);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public TopDocs rescore(TopDocs topDocs, IndexSearcher searcher, RescoreContext r
// We will truncate the {@link TopDocs} to the window size so rescoring will be done on the full topDocs.
topDocs = topN(topDocs, rescoreContext.getWindowSize());


// Save doc IDs for which rescoring was applied to be used in score explanation
Set<Integer> topDocIDs = Arrays.stream(topDocs.scoreDocs).map(scoreDoc -> scoreDoc.doc).collect(toUnmodifiableSet());
rescoreContext.setRescoredDocs(topDocIDs);
Expand Down Expand Up @@ -134,7 +133,6 @@ public Explanation explain(int topLevelDocId, IndexSearcher searcher, RescoreCon
return null;
}


/** Returns a new {@link TopDocs} with the topN from the incoming one, or the same TopDocs if the number of hits is already &lt;=
* topN. */
private static TopDocs topN(TopDocs in, int topN) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ public ActionRequestValidationException validate(SearchRequest searchRequest, Ac
RescorerBuilder<?> nextRescorer = rescorers.get(i);
int nextRescorerWindowSize = nextRescorer.windowSize() != null ? nextRescorer.windowSize() : DEFAULT_WINDOW_SIZE;
if (windowSize() < nextRescorerWindowSize) {
return addValidationError("unable to add a rescorer with [window_size: "
+ nextRescorer.windowSize()
+ "] because a rescorer of type ["
+ nextRescorer.getWriteableName()
+ "] with a smaller [window_size: "
+ windowSize()
+ "] has been added before",
validationException);
return addValidationError(
"unable to add a rescorer with [window_size: "
+ nextRescorer.windowSize()
+ "] because a rescorer of type ["
+ nextRescorer.getWriteableName()
+ "] with a smaller [window_size: "
+ windowSize()
+ "] has been added before",
validationException
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,15 @@ protected Writeable.Reader<LearningToRankRescorerBuilder> instanceReader() {
return in -> new LearningToRankRescorerBuilder(in, learningToRankService);
}


protected LearningToRankRescorerBuilder createTestInstance(int windowSize) {
LearningToRankRescorerBuilder builder = randomBoolean()
? createXContextTestInstance(null)
: new LearningToRankRescorerBuilder(
randomAlphaOfLength(10),
randomLearningToRankConfig(),
randomBoolean() ? randomParams() : null,
learningToRankService
);
randomAlphaOfLength(10),
randomLearningToRankConfig(),
randomBoolean() ? randomParams() : null,
learningToRankService
);

builder.windowSize(windowSize);

Expand Down

0 comments on commit 2dc4e4d

Please sign in to comment.