| Code with Finding: |
class ReqOptSumScorer {
/** Returns the score of the current document matching the query.
* Initially invalid, until {@link #next()} is called the first time.
* @return The score of the required scorer, eventually increased by the score
* of the optional scorer when it also matches the current document.
*/
public float score() throws IOException {
int curDoc = reqScorer.doc();
float reqScore = reqScorer.score();
if (firstTimeOptScorer) {
firstTimeOptScorer = false;
if (! optScorer.skipTo(curDoc)) {
optScorer = null;
return reqScore;
}
} else if (optScorer == null) {
return reqScore;
} else if ((optScorer.doc() < curDoc) && (! optScorer.skipTo(curDoc))) {
optScorer = null;
return reqScore;
}
// assert (optScorer != null) && (optScorer.doc() >= curDoc);
return (optScorer.doc() == curDoc)
? reqScore + optScorer.score()
: reqScore;
}
}
|