[GitHub] [lucene-solr] jpountz commented on a change in pull request #667: Use exponential search in IntArrayDocIdSetIterator#advance
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: 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
[GitHub] [lucene-solr] jpountz commented on a change in pull request #667: Use exponential search in IntArrayDocIdSetIterator#advance
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_r283151316 ## 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); Review comment: it feels a bit wrong to me that i==-1 needs a special case. 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
[GitHub] [lucene-solr] jpountz commented on a change in pull request #667: Use exponential search in IntArrayDocIdSetIterator#advance
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