-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: RoaringBitmap::from_lsb0_bytes
#288
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lemolatoon 👋
Thank you very much for these changes. The results look very good, indeed. However, could you:
- Write a better explanation of what
offset
means. I understand, but it needs to be clearer. Maybe talk about internal containers that are aligned around 64k values integer groups? - Explain what kind of input is expected in plain text in the function description (endianness, size, alignment).
- Move this function and the test into the serialization module.
Thank you very much for the work!
83af352
to
adbc00b
Compare
Hi @Kerollmops 👋 Thank you for your quick reply. I have just made changes based on your review. Basically I did:
|
adbc00b
to
af5ea01
Compare
af5ea01
to
03a61ad
Compare
@Dr-Emann I've just fixed the documentation and made the implementation endian-aware. |
I applied @Kerollmops I would like you to review this pull requests, then I can see the CI result. |
RoaringBitmap::from_bitmap_bytes
RoaringBitmap::from_lsb0_bytes
Hey @lemolatoon 👋 Sorry for the very late reply. I just approved your changes so that you can see the CI. |
Thank you @Kerollmops ! |
@lemolatoon The CI errors should be fixed by pulling in main, thanks to #293. |
2706bd9
to
ac672a5
Compare
I |
It seems to have the clippy warnings appeared only in 1.66.0 not in stable. I fixed the warnings. Could you re-run CI again please? @Kerollmops |
Hey @lemolatoon 👋 Would you mind rebasing on main, please? I just merged #295. Have a nice one 🐿️ |
* Directly create an array/bitmap store based on the count of bits * Use u64 words to count bits and enumerate bits * Store in little endian, then just fixup any touched words * Only use unsafe to reinterpret a whole bitmap container as bytes, everything else is safe * Allow adding bytes up to the last possible offset
we can setting an initial value in that case
e72b0fc
to
915e582
Compare
@Kerollmops
I am afraid to bother you multiple times, but I'd like to see the CI result again 🙏 |
The Feature Explanation
RoaringBitmap
Function Behavior
RoaringBitmap
offset
can be used to offset the passing bitmap's indexoffset
is not aligned to # of bits ofContainer
'sStore::Bitmap
(# of bits ofBox<[u64; 1024]>
), this function panicsMotivation
Sometimes bitmap is calculated by SIMD instructions. The result of SIMD instruction is likely to be already bitmask, not the series of bitmap indicies.
Under current implementation, when you intend use
RoaringBitmap
with bitmask produced by SIMD instruction, you have to useRoaringBitmap::sorted_iter
or just insert one by one.To solve this problem, I implemented
RoaringBitmap::from_bitmap_bytes
, which can be used to construct directly from bitmask.Example of Production of Bitmask by SIMD instructions
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=40ddd13554c171be31fe53893401d40f
Benchmark Result
On my laptop (Apple M3 MacBook Air Sonoma14.3 Memory 16 GB), in most cases
from_lsb0_bytes
is much faster thanfrom_sorted_iter
.Part of Results