This is an automated email from the ASF dual-hosted git repository.
yashmayya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new f147b93b994 Cache ImmutableRoaringBitmap in NullValueVectorReaderImpl
to avoid repeated deserialization (#18145)
f147b93b994 is described below
commit f147b93b994b903bb92d3a9b44f74d100398515e
Author: Deep Patel <[email protected]>
AuthorDate: Thu Apr 9 11:06:47 2026 -0700
Cache ImmutableRoaringBitmap in NullValueVectorReaderImpl to avoid repeated
deserialization (#18145)
---
.../segment/index/readers/NullValueVectorReaderImpl.java | 10 +++++++++-
.../index/readers/NullValueVectorReaderImplTest.java | 13 +++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImpl.java
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImpl.java
index ccd79a2d7a2..61d74816f60 100644
---
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImpl.java
+++
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImpl.java
@@ -26,6 +26,9 @@ import org.roaringbitmap.buffer.ImmutableRoaringBitmap;
public class NullValueVectorReaderImpl implements NullValueVectorReader {
private final PinotDataBuffer _dataBuffer;
+ // Cached bitmap to avoid re-deserializing from the underlying buffer on
every call.
+ // ImmutableRoaringBitmap is thread-safe once constructed, so a volatile
field is sufficient.
+ private volatile ImmutableRoaringBitmap _nullBitmap;
public NullValueVectorReaderImpl(PinotDataBuffer dataBuffer) {
_dataBuffer = dataBuffer;
@@ -37,6 +40,11 @@ public class NullValueVectorReaderImpl implements
NullValueVectorReader {
@Override
public ImmutableRoaringBitmap getNullBitmap() {
- return new ImmutableRoaringBitmap(_dataBuffer.toDirectByteBuffer(0, (int)
_dataBuffer.size()));
+ ImmutableRoaringBitmap nullBitmap = _nullBitmap;
+ if (nullBitmap == null) {
+ nullBitmap = new
ImmutableRoaringBitmap(_dataBuffer.toDirectByteBuffer(0, (int)
_dataBuffer.size()));
+ _nullBitmap = nullBitmap;
+ }
+ return nullBitmap;
}
}
diff --git
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImplTest.java
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImplTest.java
index 62908fba494..20797187db2 100644
---
a/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImplTest.java
+++
b/pinot-segment-local/src/test/java/org/apache/pinot/segment/local/segment/index/readers/NullValueVectorReaderImplTest.java
@@ -62,6 +62,19 @@ public class NullValueVectorReaderImplTest implements
PinotBuffersAfterMethodChe
}
}
+ @Test
+ public void testNullBitmapIsCached()
+ throws IOException {
+ File nullValueFile = new File(TEMP_DIR, TEMP_DIR.list()[0]);
+ try (PinotDataBuffer buffer =
PinotDataBuffer.loadBigEndianFile(nullValueFile)) {
+ NullValueVectorReaderImpl reader = new NullValueVectorReaderImpl(buffer);
+ // Repeated calls to getNullBitmap() must return the same instance, not
reconstruct it
+ org.roaringbitmap.buffer.ImmutableRoaringBitmap first =
reader.getNullBitmap();
+ org.roaringbitmap.buffer.ImmutableRoaringBitmap second =
reader.getNullBitmap();
+ Assert.assertSame(first, second, "getNullBitmap() should return the
cached instance on repeated calls");
+ }
+ }
+
@AfterClass
public void tearDown()
throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]