You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by mi...@apache.org on 2009/02/09 12:26:20 UTC
svn commit: r742406 -
/lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
Author: mikemccand
Date: Mon Feb 9 11:26:20 2009
New Revision: 742406
URL: http://svn.apache.org/viewvc?rev=742406&view=rev
Log:
LUCENE-1538: don't bottlneck threads on IndexReader.isDeleted in ValueSourceQuery
Modified:
lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
Modified: lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java?rev=742406&r1=742405&r2=742406&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/function/ValueSourceQuery.java Mon Feb 9 11:26:20 2009
@@ -18,6 +18,7 @@
*/
import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.TermDocs;
import org.apache.lucene.search.*;
import org.apache.lucene.util.ToStringUtils;
@@ -108,53 +109,40 @@
* be used. (assuming field is indexed for this doc, with a single token.)
*/
private class ValueSourceScorer extends Scorer {
- private final IndexReader reader;
private final ValueSourceWeight weight;
- private final int maxDoc;
private final float qWeight;
- private int doc=-1;
private final DocValues vals;
+ private final TermDocs termDocs;
// constructor
private ValueSourceScorer(Similarity similarity, IndexReader reader, ValueSourceWeight w) throws IOException {
super(similarity);
this.weight = w;
this.qWeight = w.getValue();
- this.reader = reader;
- this.maxDoc = reader.maxDoc();
// this is when/where the values are first created.
vals = valSrc.getValues(reader);
+ termDocs = reader.termDocs(null);
}
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#next() */
public boolean next() throws IOException {
- for(;;) {
- ++doc;
- if (doc>=maxDoc) {
- return false;
- }
- if (reader.isDeleted(doc)) {
- continue;
- }
- return true;
- }
+ return termDocs.next();
}
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#doc()
*/
public int doc() {
- return doc;
+ return termDocs.doc();
}
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#score() */
public float score() throws IOException {
- return qWeight * vals.floatVal(doc);
+ return qWeight * vals.floatVal(termDocs.doc());
}
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#skipTo(int) */
public boolean skipTo(int target) throws IOException {
- doc=target-1;
- return next();
+ return termDocs.skipTo(target);
}
/*(non-Javadoc) @see org.apache.lucene.search.Scorer#explain(int) */