diff --git a/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java b/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java index 9fc4727797e2..dd191d3bb35d 100644 --- a/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java +++ b/paimon-common/src/main/java/org/apache/paimon/utils/RoaringBitmap32.java @@ -26,6 +26,7 @@ import java.io.DataOutput; import java.io.IOException; import java.nio.ByteBuffer; +import java.util.Iterator; import java.util.Objects; /** A compressed bitmap for 32-bit integer. */ @@ -103,6 +104,19 @@ public void deserialize(byte[] rbmBytes) throws IOException { roaringBitmap.deserialize(ByteBuffer.wrap(rbmBytes)); } + public void flip(final long rangeStart, final long rangeEnd) { + roaringBitmap.flip(rangeStart, rangeEnd); + } + + public Iterator iterator() { + return roaringBitmap.iterator(); + } + + @Override + public String toString() { + return roaringBitmap.toString(); + } + @VisibleForTesting public static RoaringBitmap32 bitmapOf(int... dat) { RoaringBitmap32 roaringBitmap32 = new RoaringBitmap32(); @@ -119,4 +133,20 @@ public static RoaringBitmap32 and(final RoaringBitmap32 x1, final RoaringBitmap3 public static RoaringBitmap32 or(final RoaringBitmap32 x1, final RoaringBitmap32 x2) { return new RoaringBitmap32(RoaringBitmap.or(x1.roaringBitmap, x2.roaringBitmap)); } + + public static RoaringBitmap32 or(Iterator iterator) { + return new RoaringBitmap32( + RoaringBitmap.or( + new Iterator() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public RoaringBitmap next() { + return iterator.next().roaringBitmap; + } + })); + } }