mirror of https://github.com/apache/lucene.git
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:
parent
8c0d242750
commit
8456ba93f8
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue