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_r283151360
 
 

 ##########
 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) {
 
 Review comment:
   I think it's unlikely to happen in practice since we use it for small 
arrays, but should we protect against integer overflow? Or at least add a 
comment that explains why this can't overflow?

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to