Simplify dense optimization check in TermInSetQuery (#11737)

This commit is contained in:
Greg Miller 2022-09-02 07:51:29 -07:00 committed by GitHub
parent 202dd809bd
commit 84cae4f27c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 9 deletions

View File

@ -281,10 +281,11 @@ public class TermInSetQuery extends Query implements Accountable {
for (BytesRef term = iterator.next(); term != null; term = iterator.next()) {
assert field.equals(iterator.field());
if (termsEnum.seekExact(term)) {
if (reader.maxDoc() == termsEnum.docFreq()) {
return new WeightOrDocIdSet(DocIdSet.all(reader.maxDoc()));
}
if (matchingTerms == null) {
if (reader.maxDoc() == termsEnum.docFreq()) {
return new WeightOrDocIdSet(DocIdSet.all(reader.maxDoc()));
}
docs = termsEnum.postings(docs, PostingsEnum.NONE);
builder.add(docs);
} else if (matchingTerms.size() < threshold) {
@ -292,16 +293,10 @@ public class TermInSetQuery extends Query implements Accountable {
} else {
assert matchingTerms.size() == threshold;
builder = new DocIdSetBuilder(reader.maxDoc(), terms);
if (reader.maxDoc() == termsEnum.docFreq()) {
return new WeightOrDocIdSet(DocIdSet.all(reader.maxDoc()));
}
docs = termsEnum.postings(docs, PostingsEnum.NONE);
builder.add(docs);
for (TermAndState t : matchingTerms) {
t.termsEnum.seekExact(t.term, t.state);
if (reader.maxDoc() == t.docFreq) {
return new WeightOrDocIdSet(DocIdSet.all(reader.maxDoc()));
}
docs = t.termsEnum.postings(docs, PostingsEnum.NONE);
builder.add(docs);
}