#bitmap #zero-copy

splinter-rs

A compressed bitmap format optimized for small, sparse sets of u32s with zero-copy querying

1 unstable release

Uses new Rust 2024

new 0.1.0 Mar 29, 2025

#199 in Compression

42 downloads per month

MIT/Apache

73KB
2K SLoC

Splinter

docs.rs   crates.io

Splinter is a compressed bitmap format similar to Roaring, optimized specifically for small, sparse sets of 32-bit unsigned integers (u32).

Key Features:

  • Tree-based Encoding: Splinter encodes u32 values into a 256-way tree structure by decomposing integers into big-endian component bytes. Leaf nodes efficiently transition from byte lists to compact bitmaps at up to 32 values.

  • Zero-copy Access: Designed for efficient querying without deserialization, the SplinterRef type allows direct, zero-copy reads from any type implementing AsRef<[u8]>.

Serialized Format

header (4 bytes)
    magic (2 bytes)
    unused (2 bytes)

footer (4 bytes)
    partitions (2 bytes)
    unused (2 bytes)

block (cardinality)
    cardinality == 256
        data: OMITTED
    cardinality < 32
        data: [u8; cardinality]
    else
        data: [u8; 32]

index (cardinality, offset_size: u16|u32)
    keys: block(cardinality)
    cardinalities: [u8; cardinality] // 1 based
    offsets: [offset_size; cardinality]

map (cardinality, off_type, val_type)
    values: [val_type(index->cardinalities[i]); cardinality]
    index (cardinality, off_type)

splinter
    header
    map (footer->partitions, u32,
      map (cardinality, u32,
        map (cardinality, u16, block)))
    footer

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.6–2.2MB
~38K SLoC