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 MissingValues for Lucene 10 #17647

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -324,7 +324,8 @@ public boolean advanceExact(int doc) throws IOException {

@Override
public int docValueCount() {
return values.docValueCount();
// If we don't have ordinals, then we just have the missing value
return hasOrds ? values.docValueCount() : 1;
}

@Override
Expand Down Expand Up @@ -359,7 +360,8 @@ public long getValueCount() {

@Override
public int docValueCount() {
return Math.max(1, values.docValueCount());
// If we don't have ordinals, then we just have the missing value
return hasOrds ? values.docValueCount() : 1;
}
Copy link
Contributor

@expani expani Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nextOrd() just below this is also not checking for docValueCount.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's okay. If the caller calls nextOrd() too many times, the behavior is undefined.


@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public long nextOrd() {
if (i < ords[doc].length) {
return ords[doc][i++];
} else {
return NO_MORE_DOCS;
throw new IllegalStateException();
}
}

Expand All @@ -175,13 +175,13 @@ public int docValueCount() {
for (int i = 0; i < numDocs; ++i) {
assertTrue(withMissingReplaced.advanceExact(i));
if (ords[i].length > 0) {
assertEquals(ords[i].length, withMissingReplaced.docValueCount());
for (int ord : ords[i]) {
assertEquals(values[ord], withMissingReplaced.lookupOrd(withMissingReplaced.nextOrd()));
}
assertEquals(SortedSetDocValues.NO_MORE_DOCS, withMissingReplaced.nextOrd());
} else {
assertEquals(1, withMissingReplaced.docValueCount());
assertEquals(missing, withMissingReplaced.lookupOrd(withMissingReplaced.nextOrd()));
assertEquals(SortedSetDocValues.NO_MORE_DOCS, withMissingReplaced.nextOrd());
}
}
}
Expand Down
Loading