benwtrent commented on code in PR #14523:
URL: https://github.com/apache/lucene/pull/14523#discussion_r2050722768
##########
lucene/core/src/java/org/apache/lucene/search/comparators/NumericComparator.java:
##########
@@ -434,6 +434,9 @@ public void intoBitSet(int upTo, FixedBitSet bitSet, int
offset) throws IOExcept
if (competitiveIterator.docID() < doc) {
competitiveIterator.advance(doc);
}
+ if (doc >= upTo) {
+ return;
+ }
Review Comment:
We have this check in many (if not all?) of the intoBitSet implementations,
seemed sane to put it here as well, don't bother calling it if we advanced past
`upTo`.
##########
lucene/core/src/java/org/apache/lucene/search/DisjunctionDISIApproximation.java:
##########
@@ -146,7 +146,13 @@ public int advance(int target) throws IOException {
@Override
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws
IOException {
while (leadTop.doc < upTo) {
- leadTop.approximation.intoBitSet(upTo, bitSet, offset);
+ int intoBitSetBase = offset;
+ if (leadTop.approximation.docID() < offset) {
+ intoBitSetBase = leadTop.approximation.advance(offset);
+ }
+ if (intoBitSetBase < upTo) {
+ leadTop.approximation.intoBitSet(upTo, bitSet, intoBitSetBase);
+ }
Review Comment:
It seemed weird to me that we have this inconsistency in the API between
DCBS and the disjunction checker. So, I added advancement here as well,
guarding the `intoBitSet` similarly.
##########
lucene/core/src/java/org/apache/lucene/search/comparators/TermOrdValComparator.java:
##########
@@ -524,6 +524,7 @@ public int advance(int target) throws IOException {
@Override
public void intoBitSet(int upTo, FixedBitSet bitSet, int offset) throws
IOException {
+ upTo = Math.min(upTo, maxDoc);
Review Comment:
Similar protection that Chris found. Its possible that iteration past `max`
might break things in unexpected ways. Let's protect it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]