You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2022/09/02 15:10:35 UTC

[lucene] branch branch_9x updated: Simplify dense optimization check in TermInSetQuery (#11737)

This is an automated email from the ASF dual-hosted git repository.

gsmiller pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/branch_9x by this push:
     new bc841cf9467 Simplify dense optimization check in TermInSetQuery (#11737)
bc841cf9467 is described below

commit bc841cf946744b986d9881defd5d34ec27e76cb9
Author: Greg Miller <gs...@gmail.com>
AuthorDate: Fri Sep 2 07:51:29 2022 -0700

    Simplify dense optimization check in TermInSetQuery (#11737)
---
 .../src/java/org/apache/lucene/search/TermInSetQuery.java   | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
index a0016d61ba7..20982d6be63 100644
--- a/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/TermInSetQuery.java
@@ -277,10 +277,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) {
@@ -288,16 +289,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);
               }