clean up BS2's Coordinator, use ctor instead of init, make coordFactors final

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1371630 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2012-08-10 09:51:45 +00:00
parent d5212c9ae2
commit 93ebd8d5bd
1 changed files with 6 additions and 8 deletions

View File

@ -41,16 +41,16 @@ class BooleanScorer2 extends Scorer {
private final List<Scorer> prohibitedScorers;
private class Coordinator {
float[] coordFactors = null;
int maxCoord = 0; // to be increased for each non prohibited scorer
int nrMatchers; // to be increased by score() of match counting scorers.
void init(boolean disableCoord) { // use after all scorers have been added.
final float coordFactors[];
Coordinator(int maxCoord, boolean disableCoord) {
coordFactors = new float[optionalScorers.size() + requiredScorers.size() + 1];
for (int i = 0; i < coordFactors.length; i++) {
coordFactors[i] = disableCoord ? 1.0f : ((BooleanWeight)weight).coord(i, maxCoord);
}
}
int nrMatchers; // to be increased by score() of match counting scorers.
}
private final Coordinator coordinator;
@ -92,15 +92,13 @@ class BooleanScorer2 extends Scorer {
if (minNrShouldMatch < 0) {
throw new IllegalArgumentException("Minimum number of optional scorers should not be negative");
}
coordinator = new Coordinator();
this.minNrShouldMatch = minNrShouldMatch;
coordinator.maxCoord = maxCoord;
optionalScorers = optional;
requiredScorers = required;
prohibitedScorers = prohibited;
coordinator = new Coordinator(maxCoord, disableCoord);
coordinator.init(disableCoord);
countingSumScorer = makeCountingSumScorer(disableCoord);
}