feat: Add roaring feature with GetSize impls for RoaringBitmap and RoaringTreemap#49
Merged
Conversation
- Add debug_assert on the u64→usize cast so an upstream invariant breach surfaces in debug while still saturating in release. - Tighten test assertions to compare exactly against the sum of all three container-flavor totals, catching a dropped flavor. - Exercise non-trivial per-bitmap heap size in the treemap test. - Trim comments to WHY-only and unify the tracker type-param name.
Owner
|
fucked up the merge xD |
bircni
approved these changes
Jun 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
roaringfeature withGetSizeimpls forroaring::RoaringBitmapandroaring::RoaringTreemap, following the established pattern from thedashmap/half/parking_lotfeatures (#46, #47, #48).Implementation
RoaringBitmap: sumsstatistics().n_bytes_{array,bitset,run}_containers. TheStatisticsAPI already walks every container internally and reports per-flavor byte totals (capacity()-based for array and run, fixed 8 KiB for bitset), so no internal access to private container types is needed.Vec<Container>slot allocation (Containerispub(crate), so its size isn't accessible from outside the crate) and per-container tag/key fields.RoaringTreemap: internally aBTreeMap<u32, RoaringBitmap>. The map is private but thebitmaps()method exposes a public iterator over(u32, &RoaringBitmap). Mirrors the existingBTreeMap<K, V>impl incollections.rs— per-entry adds stack-size + heap-size of both key and value, doesn't attempt to account for BTreeMap node padding.Tests
test_roaring_bitmap: empty, array container, bitset container, run container (viaoptimize()), tracker-variant path.test_roaring_treemap: empty, two-partition treemap matching the sum of contained bitmaps, tracker-variant path.Notes
roaringmatches the published crate name on crates.io (the-rsis only in the GitHub repo name, same convention asparking_lotwhose repo isAmanieu/parking_lot).default-features = falseon the dep to preserveno_std-compatibility for downstream users.