#35823 - Paul Elschots fix for BooleanScorer2 causing ArrayIndexOutOfBoundsException

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@220228 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2005-07-22 01:48:32 +00:00
parent 3227a9dfb8
commit 7dd3e02a1a
1 changed files with 17 additions and 3 deletions

View File

@ -99,12 +99,17 @@ class BooleanScorer2 extends Scorer {
/** Count a scorer as a single match. */
private class SingleMatchScorer extends Scorer {
private Scorer scorer;
private int lastScoredDoc = -1;
SingleMatchScorer(Scorer scorer) {
super(scorer.getSimilarity());
this.scorer = scorer;
}
public float score() throws IOException {
coordinator.nrMatchers++;
if (doc() > lastScoredDoc) {
lastScoredDoc = doc();
coordinator.nrMatchers++;
}
return scorer.score();
}
public int doc() {
@ -125,8 +130,12 @@ class BooleanScorer2 extends Scorer {
// each scorer from the list counted as a single matcher
{
return new DisjunctionSumScorer(scorers) {
private int lastScoredDoc = -1;
public float score() throws IOException {
coordinator.nrMatchers += nrMatchers;
if (doc() > lastScoredDoc) {
lastScoredDoc = doc();
coordinator.nrMatchers += super.nrMatchers;
}
return super.score();
}
};
@ -139,8 +148,13 @@ class BooleanScorer2 extends Scorer {
{
final int requiredNrMatchers = requiredScorers.size();
ConjunctionScorer cs = new ConjunctionScorer(defaultSimilarity) {
private int lastScoredDoc = -1;
public float score() throws IOException {
coordinator.nrMatchers += requiredNrMatchers;
if (doc() > lastScoredDoc) {
lastScoredDoc = doc();
coordinator.nrMatchers += requiredNrMatchers;
}
// All scorers match, so defaultSimilarity super.score() always has 1 as
// the coordination factor.
// Therefore the sum of the scores of the requiredScorers