jpountz commented on a change in pull request #667: Use exponential search in
IntArrayDocIdSetIterator#advance
URL: https://github.com/apache/lucene-solr/pull/667#discussion_r283151220
##########
File path: lucene/core/src/java/org/apache/lucene/util/IntArrayDocIdSet.java
##########
@@ -72,7 +72,12 @@ public int nextDoc() throws IOException {
@Override
public int advance(int target) throws IOException {
- i = Arrays.binarySearch(docs, i + 1, length, target);
+ int bound = 1;
+ int offset = Math.max(0, i);
+ while(offset + bound < length && docs[offset + bound] < target) {
+ bound *= 2;
+ }
+ i = Arrays.binarySearch(docs, offset + bound / 2, Math.min(offset +
bound, length), target);
Review comment:
`bound/2` is generally the previous bound that we tested, except when
`bound` is equal to 1. It won't break in that case since callers are not
supposed to call advance on a target that is lte the current doc ID, but this
might still make room for bugs?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]