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

Fixes failing test case for TestOrdinalMap.testRamBytesUsed #13421

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ Bug Fixes

* GITHUB#13376: Fix integer overflow exception in postings encoding as group-varint. (Zhang Chao, Guo Feng)

* GITHUB#13421: Fixes TestOrdinalMap.testRamBytesUsed for multiple default PackedInts.NullReader instances. (Amir Raza)

Build
---------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public String toString() {
/** A {@link Reader} which has all its values equal to 0 (bitsPerValue = 0). */
public static final class NullReader extends Reader {

private static final NullReader DEFAULT_PACKED_LONG_VALUES_PAGE_SIZE =
public static final NullReader DEFAULT_PACKED_LONG_VALUES_PAGE_SIZE =
new NullReader(PackedLongValues.DEFAULT_PAGE_SIZE);

private final int valueCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.lucene.tests.util.TestUtil;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LongValues;
import org.apache.lucene.util.packed.PackedInts;

public class TestOrdinalMap extends LuceneTestCase {

Expand All @@ -52,7 +53,9 @@ public long accumulateObject(
long shallowSize,
java.util.Map<Field, Object> fieldValues,
java.util.Collection<Object> queue) {
if (o == LongValues.ZEROES || o == LongValues.IDENTITY) {
if (o == LongValues.ZEROES
|| o == LongValues.IDENTITY
|| o == PackedInts.NullReader.DEFAULT_PACKED_LONG_VALUES_PAGE_SIZE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can you replace this with PackedInts.NullReader.forCount(PackedLongValues.DEFAULT_PAGE_SIZE) and make DEFAULT_PACKED_LONG_VALUES_PAGE_SIZE private again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Thanks for quick review.

return 0L;
}
if (o instanceof OrdinalMap) {
Expand Down