Skip to content

feat(util): add Mumbling bitmap writer - #1195

Open
xndai wants to merge 1 commit into
apache:mainfrom
xndai:xndai/iceberg-cpp/B2
Open

xndai wants to merge 1 commit into
apache:mainfrom
xndai:xndai/iceberg-cpp/B2

Conversation

@xndai

@xndai xndai commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Closes #1194. Part of #1107.

Adds the write side of the Mumbling bitmap format (a draft spec, apache/iceberg#16518) for v4 manifest deletion vectors (manifest_info.dv, tracking.deleted_positions and tracking.replaced_positions). It sits next to the reader from #1126 in util/mumbling_bitmap_internal.h.

MutableMumblingBitmap matches Java's MutableBitmap (apache/iceberg#18138):

  • Set(pos) adds a position and reports whether it was new.
  • Merge(view) adds every position of an existing bitmap.
  • Serialize() writes format version 1.

As in Java, containers with fewer than 32 positions are written sparse and the rest dense. EncodePforBytes() picks the PFOR bit widths (Appendix A) the way the Java encoder does, so the output matches Java byte for byte.

Tests check the output against the Java-generated fixtures from #1126 (130 PFOR vectors and 6 bitmaps). They also round-trip empty, contiguous, clustered, random and maximum-size bitmaps through MumblingBitmapView, and cover merging bitmaps of different sizes and invalid positions. BM_PforEncode, BM_Set and BM_Serialize are added to mumbling_bitmap_benchmark.

Benchmark against the Java writer on the same positions (Release; gcc-14 with Google Benchmark, JDK 17 with JMH; Xeon Platinum 8175M):

Operation C++ Java
Set 100,000 random positions 0.92 ms 6.85 ms
Set all 2,097,152 positions 16.2 ms 120 ms
Serialize, 1,000 random positions 47 µs 62 µs
Serialize, 100,000 random positions 594 µs 428 µs
Serialize, all 2,097,152 positions 34 µs 247 µs

C++ keeps each container as a bit set, so Set is constant-time but writing a sparse container needs a bit scan. Java keeps sparse containers as sorted lists, which is why it serializes the random 100,000-position bitmap faster.

Add MutableMumblingBitmap, the write side of the Mumbling bitmap format
used by v4 manifest deletion vectors. Like Java's MutableBitmap, it
sets positions, merges existing bitmaps, and serializes to the same
bytes as the Java writer. EncodePforBytes() encodes the descriptor
array the way the Java encoder does.

Test:
- New tests in mumbling_bitmap_test.cc cover round trips through
  MumblingBitmapView, byte-for-byte equality with the Java-generated
  fixtures, merging, and invalid positions.
- New microbenchmarks: BM_PforEncode, BM_Set and BM_Serialize.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Mumbling bitmap writer for v4 manifest deletion vectors

1 participant