Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix refill logic in nextDoc(). #14185

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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