Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
8.6.2
-
None
-
None
-
New
Description
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.
default void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException { int docID; while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { visit(docID, packedValue); } }
We know that the packedValue are same for the batch of docIds, if the first doc match the range, the batch of other docIds will also match the range, so the loop seems useless.
We should call the method as follow:
public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException { if (matches(packedValue)) { int docID; while ((docID = iterator.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { visit(docID); } } }
If we should override the visit(DocIdSetIterator iterator, byte[] packedValue) in ExitableDirectoryReader$ExitableIntersectVisitor to avoid calling the default implement:
@Override public void visit(DocIdSetIterator iterator, byte[] packedValue) throws IOException { queryCancellation.checkCancelled(); in.visit(iterator, packedValue); }