Skip to content

Commit

Permalink
Fix refill logic in nextDoc(). (#14185)
Browse files Browse the repository at this point in the history
The recent optimization from #14164 interfered in a bad way with a prior
optimization.
  • Loading branch information
jpountz authored Feb 1, 2025
1 parent d2c69c1 commit b429c43
Showing 1 changed file with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -888,16 +888,7 @@ private void skipLevel0To(int target) throws IOException {
public void advanceShallow(int target) throws IOException {
if (target > level0LastDocID) { // advance level 0 skip data
doAdvanceShallow(target);

// If we are on the last doc ID of a block and we are advancing on the doc ID just beyond
// this block, then we decode the block. This may not be necessary, but this helps avoid
// having to check whether we are in a block that is not decoded yet in #nextDoc().
if (docBufferUpto == BLOCK_SIZE && target == doc + 1) {
refillDocs();
needsRefilling = false;
} else {
needsRefilling = true;
}
needsRefilling = true;
}
}

Expand All @@ -914,8 +905,13 @@ private void doAdvanceShallow(int target) throws IOException {

@Override
public int nextDoc() throws IOException {
if (doc == level0LastDocID) {
moveToNextLevel0Block();
if (doc == level0LastDocID || needsRefilling) {
if (needsRefilling) {
refillDocs();
needsRefilling = false;
} else {
moveToNextLevel0Block();
}
}

switch (encoding) {
Expand Down

0 comments on commit b429c43

Please sign in to comment.