Methods Summary |
---|
final void | add(org.apache.lucene.search.Scorer scorer)
scorers.addLast(scorer);
|
private boolean | doNext()
while (more && first().doc() < last().doc()) { // find doc w/ all clauses
more = first().skipTo(last().doc()); // skip first upto last
scorers.addLast(scorers.removeFirst()); // move first to last
}
return more; // found a doc with all clauses
|
public int | doc() return first().doc();
|
public org.apache.lucene.search.Explanation | explain(int doc)
throw new UnsupportedOperationException();
|
private org.apache.lucene.search.Scorer | first() return (Scorer)scorers.getFirst();
|
private void | init(boolean initScorers)
// compute coord factor
coord = getSimilarity().coord(scorers.size(), scorers.size());
more = scorers.size() > 0;
if(initScorers){
// move each scorer to its first entry
Iterator i = scorers.iterator();
while (more && i.hasNext()) {
more = ((Scorer)i.next()).next();
}
if (more)
sortScorers(); // initial sort of list
}
firstTime = false;
|
private org.apache.lucene.search.Scorer | last() return (Scorer)scorers.getLast();
|
public boolean | next()
if (firstTime) {
init(true);
} else if (more) {
more = last().next(); // trigger further scanning
}
return doNext();
|
public float | score()
float score = 0.0f; // sum scores
Iterator i = scorers.iterator();
while (i.hasNext())
score += ((Scorer)i.next()).score();
score *= coord;
return score;
|
public boolean | skipTo(int target)
if(firstTime) {
init(false);
}
Iterator i = scorers.iterator();
while (more && i.hasNext()) {
more = ((Scorer)i.next()).skipTo(target);
}
if (more)
sortScorers(); // re-sort scorers
return doNext();
|
private void | sortScorers()
// move scorers to an array
Scorer[] array = (Scorer[])scorers.toArray(new Scorer[scorers.size()]);
scorers.clear(); // empty the list
// note that this comparator is not consistent with equals!
Arrays.sort(array, new Comparator() { // sort the array
public int compare(Object o1, Object o2) {
return ((Scorer)o1).doc() - ((Scorer)o2).doc();
}
});
for (int i = 0; i < array.length; i++) {
scorers.addLast(array[i]); // re-build list, now sorted
}
|