diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 7146a97195eb..66fe8b4ebd57 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -77,6 +77,9 @@ Optimizations * GITHUB#13961: Replace Map with IntObjectHashMap for DV producer. (Pan Guixin) +* GITHUB#13963: Speed up nextDoc() implementations in Lucene912PostingsReader. + (Adrien Grand) + Bug Fixes --------------------- * GITHUB#13832: Fixed an issue where the DefaultPassageFormatter.format method did not format passages as intended diff --git a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java index cea329c93ca3..6da66e4ddf2a 100644 --- a/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java +++ b/lucene/core/src/java/org/apache/lucene/codecs/lucene912/Lucene912PostingsReader.java @@ -580,7 +580,7 @@ private void moveToNextLevel0Block() throws IOException { @Override public int nextDoc() throws IOException { - if (doc == level0LastDocID) { // advance skip data on level 0 + if (docBufferUpto == BLOCK_SIZE) { // advance skip data on level 0 moveToNextLevel0Block(); } @@ -875,7 +875,7 @@ private void moveToNextLevel0Block() throws IOException { @Override public int nextDoc() throws IOException { - if (doc == level0LastDocID) { // advance level 0 skip data + if (docBufferUpto == BLOCK_SIZE) { // advance level 0 skip data moveToNextLevel0Block(); } @@ -1417,11 +1417,13 @@ private void moveToNextLevel0Block() throws IOException { @Override public int nextDoc() throws IOException { - if (doc == level0LastDocID) { - moveToNextLevel0Block(); - } else if (needsRefilling) { - refillDocs(); - needsRefilling = false; + if (docBufferUpto == BLOCK_SIZE) { + if (needsRefilling) { + refillDocs(); + needsRefilling = false; + } else { + moveToNextLevel0Block(); + } } return this.doc = (int) docBuffer[docBufferUpto++]; @@ -1644,8 +1646,9 @@ public void advanceShallow(int target) throws IOException { @Override public int nextDoc() throws IOException { - advanceShallow(doc + 1); - if (needsRefilling) { + if (docBufferUpto == BLOCK_SIZE) { + advanceShallow(doc + 1); + assert needsRefilling; refillDocs(); needsRefilling = false; }