Methods Summary |
---|
final void | add(org.apache.lucene.search.Scorer scorer)
if (length >= scorers.length) {
// grow the array
Scorer[] temps = new Scorer[scorers.length * 2];
System.arraycopy(scorers, 0, temps, 0, length);
scorers = temps;
}
last += 1;
length += 1;
scorers[last] = scorer;
|
private boolean | doNext()
while (more && scorers[first].doc() < scorers[last].doc()) { // find doc w/ all clauses
more = scorers[first].skipTo(scorers[last].doc()); // skip first upto last
last = first; // move first to last
first = (first == length-1) ? 0 : first+1;
}
return more; // found a doc with all clauses
|
public int | doc() return scorers[first].doc();
|
public org.apache.lucene.search.Explanation | explain(int doc)
throw new UnsupportedOperationException();
|
private void | init(boolean initScorers)
// compute coord factor
coord = getSimilarity().coord(length, length);
more = length > 0;
if(initScorers){
// move each scorer to its first entry
for (int i = 0, pos = first; i < length; i++) {
if (!more) break;
more = scorers[pos].next();
pos = (pos == length-1) ? 0 : pos+1;
}
// initial sort of simulated list
if (more)
sortScorers();
}
firstTime = false;
|
public boolean | next()
if (firstTime) {
init(true);
} else if (more) {
more = scorers[last].next(); // trigger further scanning
}
return doNext();
|
public float | score()
float sum = 0.0f;
for (int i = 0; i < length; i++) {
sum += scorers[i].score();
}
return sum * coord;
|
public boolean | skipTo(int target)
if(firstTime) {
init(false);
}
for (int i = 0, pos = first; i < length; i++) {
if (!more) break;
more = scorers[pos].skipTo(target);
pos = (pos == length-1) ? 0 : pos+1;
}
if (more)
sortScorers(); // re-sort scorers
return doNext();
|
private void | sortScorers()
// squeeze the array down for the sort
if (length != scorers.length) {
Scorer[] temps = new Scorer[length];
System.arraycopy(scorers, 0, temps, 0, length);
scorers = temps;
}
// note that this comparator is not consistent with equals!
Arrays.sort(scorers, new Comparator() { // sort the array
public int compare(Object o1, Object o2) {
return ((Scorer)o1).doc() - ((Scorer)o2).doc();
}
});
first = 0;
last = length - 1;
|