From ea0646d09482d8ec9b70cf9db8b966f08a507dc4 Mon Sep 17 00:00:00 2001 From: Amir Raza <62626184+pseudo-nymous@users.noreply.github.com> Date: Tue, 28 May 2024 22:23:08 +0530 Subject: [PATCH] Fixes failing test case for TestOrdinalMap.testRamBytesUsed (#13421) --- lucene/CHANGES.txt | 2 ++ .../org/apache/lucene/util/packed/PackedLongValues.java | 2 +- .../src/test/org/apache/lucene/index/TestOrdinalMap.java | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 29c2028eea3..092cc678960 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -402,6 +402,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 --------------------- diff --git a/lucene/core/src/java/org/apache/lucene/util/packed/PackedLongValues.java b/lucene/core/src/java/org/apache/lucene/util/packed/PackedLongValues.java index ae711262434..cda57f0fb4c 100644 --- a/lucene/core/src/java/org/apache/lucene/util/packed/PackedLongValues.java +++ b/lucene/core/src/java/org/apache/lucene/util/packed/PackedLongValues.java @@ -29,7 +29,7 @@ public class PackedLongValues extends LongValues implements Accountable { private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(PackedLongValues.class); - static final int DEFAULT_PAGE_SIZE = 256; + public static final int DEFAULT_PAGE_SIZE = 256; static final int MIN_PAGE_SIZE = 64; // More than 1M doesn't really makes sense with these appending buffers // since their goal is to try to have small numbers of bits per value diff --git a/lucene/core/src/test/org/apache/lucene/index/TestOrdinalMap.java b/lucene/core/src/test/org/apache/lucene/index/TestOrdinalMap.java index faa2aae329f..d5b3448ffa5 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestOrdinalMap.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestOrdinalMap.java @@ -30,6 +30,8 @@ import org.apache.lucene.tests.util.RamUsageTester; 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; +import org.apache.lucene.util.packed.PackedLongValues; public class TestOrdinalMap extends LuceneTestCase { @@ -52,7 +54,9 @@ public class TestOrdinalMap extends LuceneTestCase { long shallowSize, java.util.Map fieldValues, java.util.Collection queue) { - if (o == LongValues.ZEROES || o == LongValues.IDENTITY) { + if (o == LongValues.ZEROES + || o == LongValues.IDENTITY + || o == PackedInts.NullReader.forCount(PackedLongValues.DEFAULT_PAGE_SIZE)) { return 0L; } if (o instanceof OrdinalMap) {