mirror of https://github.com/apache/lucene.git
remove unneeded TermGenerator in MTQWF (no longer Filter.bits()). This is a small speed improvement.
I will apply this to 3.0, too, if a new RC comes. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@881984 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
03f6d7a649
commit
c62fb270d6
|
@ -94,8 +94,19 @@ public class MultiTermQueryWrapperFilter<Q extends MultiTermQuery> extends Filte
|
||||||
query.clearTotalNumberOfTerms();
|
query.clearTotalNumberOfTerms();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class TermGenerator {
|
/**
|
||||||
public void generate(IndexReader reader, TermEnum enumerator) throws IOException {
|
* Returns a DocIdSet with documents that should be
|
||||||
|
* permitted in search results.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
||||||
|
final TermEnum enumerator = query.getEnum(reader);
|
||||||
|
try {
|
||||||
|
// if current term in enum is null, the enum is empty -> shortcut
|
||||||
|
if (enumerator.term() == null)
|
||||||
|
return DocIdSet.EMPTY_DOCIDSET;
|
||||||
|
// else fill into a OpenBitSet
|
||||||
|
final OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
|
||||||
final int[] docs = new int[32];
|
final int[] docs = new int[32];
|
||||||
final int[] freqs = new int[32];
|
final int[] freqs = new int[32];
|
||||||
TermDocs termDocs = reader.termDocs();
|
TermDocs termDocs = reader.termDocs();
|
||||||
|
@ -111,7 +122,7 @@ public class MultiTermQueryWrapperFilter<Q extends MultiTermQuery> extends Filte
|
||||||
final int count = termDocs.read(docs, freqs);
|
final int count = termDocs.read(docs, freqs);
|
||||||
if (count != 0) {
|
if (count != 0) {
|
||||||
for(int i=0;i<count;i++) {
|
for(int i=0;i<count;i++) {
|
||||||
handleDoc(docs[i]);
|
bitSet.set(docs[i]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -124,29 +135,6 @@ public class MultiTermQueryWrapperFilter<Q extends MultiTermQuery> extends Filte
|
||||||
} finally {
|
} finally {
|
||||||
termDocs.close();
|
termDocs.close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
abstract public void handleDoc(int doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a DocIdSet with documents that should be
|
|
||||||
* permitted in search results.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
|
|
||||||
final TermEnum enumerator = query.getEnum(reader);
|
|
||||||
try {
|
|
||||||
// if current term in enum is null, the enum is empty -> shortcut
|
|
||||||
if (enumerator.term() == null)
|
|
||||||
return DocIdSet.EMPTY_DOCIDSET;
|
|
||||||
// else fill into a OpenBitSet
|
|
||||||
final OpenBitSet bitSet = new OpenBitSet(reader.maxDoc());
|
|
||||||
new TermGenerator() {
|
|
||||||
@Override
|
|
||||||
public void handleDoc(int doc) {
|
|
||||||
bitSet.set(doc);
|
|
||||||
}
|
|
||||||
}.generate(reader, enumerator);
|
|
||||||
return bitSet;
|
return bitSet;
|
||||||
} finally {
|
} finally {
|
||||||
enumerator.close();
|
enumerator.close();
|
||||||
|
|
Loading…
Reference in New Issue