Changed explain method to use TermDocs.skipTo instead of looping.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@433081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Grant Ingersoll 2006-08-20 23:11:00 +00:00
parent 8c0d242750
commit 8456ba93f8
1 changed files with 6 additions and 5 deletions

View File

@ -157,7 +157,6 @@ final class TermScorer extends Scorer {
* <br>When this method is used, the {@link #next()} method
* and the {@link #score(HitCollector)} method should not be used.
* @param doc The document number for the explanation.
* @todo Modify to make use of {@link TermDocs#skipTo(int)}.
*/
public Explanation explain(int doc) throws IOException {
TermQuery query = (TermQuery)weight.getQuery();
@ -169,11 +168,13 @@ final class TermScorer extends Scorer {
pointer++;
}
if (tf == 0) {
while (termDocs.next()) {
if (termDocs.doc() == doc) {
tf = termDocs.freq();
if (termDocs.skipTo(doc))
{
if (termDocs.doc() == doc)
{
tf = termDocs.freq();
}
}
}
}
termDocs.close();
tfExplanation.setValue(getSimilarity().tf(tf));