Skip to main content

Module bitmap

Module bitmap 

Source
Expand description

Roaring bitmap types backed by the Memory trait.

Application code should construct values with RoaringBitmap::init. This module documents the stable layout; RoaringBitmap documents runtime behavior and per-method costs.

§V1 layout

---------------------------------------- <- Address 0
Magic `RSB`                 ↕ 3 bytes
----------------------------------------
Layout version              ↕ 1 byte
----------------------------------------
Logical length (`len_bits`) ↕ 8 bytes
----------------------------------------
Journal slot count          ↕ 8 bytes
----------------------------------------
Snapshot length             ↕ 8 bytes
----------------------------------------
Reserved space              ↕ 36 bytes
---------------------------------------- <- Address 64
Mutation record 0           ↕ 5 bytes
----------------------------------------
Mutation record 1           ↕ 5 bytes
----------------------------------------
...
----------------------------------------
Mutation record N - 1       ↕ 5 bytes
---------------------------------------- <- 64 + JOURNAL_CAP_SLOTS * 5
Zero padding                ↕ 0..7 bytes
---------------------------------------- <- snapshot_base = align_up(journal end, 8)
Serialized Roaring snapshot ↕ variable length

The header is 64 bytes. Journal records are packed into five bytes, and the snapshot begins at the next eight-byte boundary. The snapshot uses the standard roaring::RoaringBitmap serialization format.

§Compatibility and recovery

JOURNAL_CAP_SLOTS is stored in the header. A build with a different capacity has a different journal and snapshot offset, so it cannot reopen existing memory without an application-level migration; RoaringBitmap::init returns InitError::InvalidLayout.

Recovery validates the reachable header and snapshot, then replays journal records until the first empty record. It deliberately does not inspect unreachable bytes after that point. The caller must therefore keep the memory region isolated from untrusted writers.

The header version describes this crate’s layout, not the roaring crate version. Compatibility with the supported Roaring serialization format is covered by a checked-in historical fixture.

Structs§

ContainsView
Borrowed guard over the heap mirror for batched Self::contains calls.
RoaringBitmap
Stable roaring bitmap with a heap mirror and a durable journal.

Enums§

BitmapError
Error returned by RoaringBitmap::new and mutating methods (set, ensure_len, checkpoint I/O, …).
InitError
Error returned when RoaringBitmap::init rejects stable memory contents.