LUCENE-1427: speed up QueryWrapperFilter by not computing scores nor an intermediate OpenBitSet

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@709459 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2008-10-31 16:18:13 +00:00
parent 0ee1707d9f
commit 4990152243
3 changed files with 17 additions and 9 deletions

View File

@ -12,6 +12,9 @@ API Changes
Yet, it will give us the possibility to try out different consumers in Yet, it will give us the possibility to try out different consumers in
in the chain. (Michael Busch) in the chain. (Michael Busch)
2. LUCENE-1427: DocIdSet.iterator() is now allowed to throw
IOException. (Paul Elschot, Mike McCandless)
Bug fixes Bug fixes
1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals() 1. LUCENE-1415: MultiPhraseQuery has incorrect hashCode() and equals()
@ -38,6 +41,12 @@ New features
Optimizations Optimizations
1. LUCENE-1427: Fixed QueryWrapperFilter to not waste time computing
scores of the query, since they are just discarded. Also, made it
more efficient (single pass) by not creating & populating an
intermediate OpenBitSet (Paul Elschot, Mike McCandless)
Documentation Documentation
Build Build

View File

@ -17,11 +17,12 @@ package org.apache.lucene.search;
* limitations under the License. * limitations under the License.
*/ */
import java.io.IOException;
/** /**
* A DocIdSet contains a set of doc ids. Implementing classes must provide * A DocIdSet contains a set of doc ids. Implementing classes must provide
* a {@link DocIdSetIterator} to access the set. * a {@link DocIdSetIterator} to access the set.
*/ */
public abstract class DocIdSet { public abstract class DocIdSet {
public abstract DocIdSetIterator iterator(); public abstract DocIdSetIterator iterator() throws IOException;
} }

View File

@ -59,15 +59,13 @@ public class QueryWrapperFilter extends Filter {
return bits; return bits;
} }
public DocIdSet getDocIdSet(IndexReader reader) throws IOException { public DocIdSet getDocIdSet(final IndexReader reader) throws IOException {
final OpenBitSet bits = new OpenBitSet(reader.maxDoc()); final Weight weight = query.weight(new IndexSearcher(reader));
return new DocIdSet() {
new IndexSearcher(reader).search(query, new HitCollector() { public DocIdSetIterator iterator() throws IOException {
public final void collect(int doc, float score) { return weight.scorer(reader);
bits.set(doc); // set bit for hit
} }
}); };
return bits;
} }
public String toString() { public String toString() {