You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "kkewwei (Jira)" <ji...@apache.org> on 2022/04/15 04:27:00 UTC

[jira] [Created] (LUCENE-10516) reduce unnecessary loop matches in BKDReader

kkewwei created LUCENE-10516:
--------------------------------

             Summary: reduce unnecessary loop matches in BKDReader
                 Key: LUCENE-10516
                 URL: https://issues.apache.org/jira/browse/LUCENE-10516
             Project: Lucene - Core
          Issue Type: Improvement
          Components: core/other
            Reporter: kkewwei


In `BKDReader.visitSparseRawDocValues()`, we will read a batch of docIds which have the same point value:scratchPackedValue, then call `visitor.visit(scratchIterator, scratchPackedValue)` to find which docIDs match the range.

{code:java}
default void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
      int docID;
      while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { 
        visit(docID, packedValue); 
      }
    }
{code}
we know that the packedValue are same, if the first doc match the range, the batch of docIds will also match the range, so the loop is useless.

we should call the method as follow:

{code:java}
          public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException {
            if (matches(packedValue)) {
              int docID;
              while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
                visit(docID);
              }
            }
          }
{code}

https://github.com/apache/lucene/blob/2e941fcfed6cad3d9c8667ff5324cd04858ba547/lucene/core/src/java/org/apache/lucene/search/PointRangeQuery.java#L196




--
This message was sent by Atlassian Jira
(v8.20.1#820001)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org