This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 94bcf65099 [core] Fix npe problem in bitmap file index v2 (#5652)
94bcf65099 is described below
commit 94bcf6509978a1cba0e3d9cf2c9f70f74c932ec7
Author: Zhonghang Liu <[email protected]>
AuthorDate: Thu May 22 20:28:04 2025 +0800
[core] Fix npe problem in bitmap file index v2 (#5652)
---
.../fileindex/bitmap/BitmapFileIndexMetaV2.java | 4 +++-
.../fileindex/bitmapindex/BitmapFileIndexTest.java | 21 +++++++++++++++++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git
a/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapFileIndexMetaV2.java
b/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapFileIndexMetaV2.java
index 1b367adada..f92e008162 100644
---
a/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapFileIndexMetaV2.java
+++
b/paimon-common/src/main/java/org/apache/paimon/fileindex/bitmap/BitmapFileIndexMetaV2.java
@@ -233,7 +233,9 @@ public class BitmapFileIndexMetaV2 extends
BitmapFileIndexMeta {
LinkedList<BitmapIndexBlock> indexBlocks = new LinkedList<>();
this.indexBlocks = indexBlocks;
- indexBlocks.add(new BitmapIndexBlock(0));
+ if (!bitmapOffsets.isEmpty()) {
+ indexBlocks.add(new BitmapIndexBlock(0));
+ }
Comparator<Object> comparator = getComparator(dataType);
bitmapOffsets.entrySet().stream()
.map(
diff --git
a/paimon-common/src/test/java/org/apache/paimon/fileindex/bitmapindex/BitmapFileIndexTest.java
b/paimon-common/src/test/java/org/apache/paimon/fileindex/bitmapindex/BitmapFileIndexTest.java
index baa184fc43..cf67e9c2fe 100644
---
a/paimon-common/src/test/java/org/apache/paimon/fileindex/bitmapindex/BitmapFileIndexTest.java
+++
b/paimon-common/src/test/java/org/apache/paimon/fileindex/bitmapindex/BitmapFileIndexTest.java
@@ -111,6 +111,7 @@ public class BitmapFileIndexTest {
testBooleanType(BitmapFileIndex.VERSION_1);
testHighCardinality(BitmapFileIndex.VERSION_1, 1000000, 100000, null);
testStringTypeWithReusing(BitmapFileIndex.VERSION_1);
+ testAllNull(BitmapFileIndex.VERSION_1);
}
@Test
@@ -120,6 +121,7 @@ public class BitmapFileIndexTest {
testBooleanType(BitmapFileIndex.VERSION_2);
testHighCardinality(BitmapFileIndex.VERSION_2, 1000000, 100000, null);
testStringTypeWithReusing(BitmapFileIndex.VERSION_2);
+ testAllNull(BitmapFileIndex.VERSION_2);
}
private FileIndexReader createTestReaderOnWriter(
@@ -204,6 +206,25 @@ public class BitmapFileIndexTest {
assert !reader.visitEqual(fieldRef, 2).remain();
}
+ private void testAllNull(int version) throws Exception {
+ FieldRef fieldRef = new FieldRef(0, "", DataTypes.INT());
+ Object[] dataColumn = {null, null, null};
+ FileIndexReader reader =
+ createTestReaderOnWriter(
+ version,
+ null,
+ DataTypes.INT(),
+ writer -> {
+ for (Object o : dataColumn) {
+ writer.write(o);
+ }
+ });
+ assert ((BitmapIndexResult) reader.visitIsNull(fieldRef))
+ .get()
+ .equals(RoaringBitmap32.bitmapOf(0, 1, 2));
+ assert !reader.visitIsNotNull(fieldRef).remain();
+ }
+
private void testBooleanType(int version) throws Exception {
FieldRef fieldRef = new FieldRef(0, "", DataTypes.BOOLEAN());
Object[] dataColumn = {Boolean.TRUE, Boolean.FALSE, Boolean.TRUE,
Boolean.FALSE, null};