Skip to content
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: optimized counter? #463

Open
whyrusleeping opened this issue Dec 4, 2024 · 5 comments
Open

Feature Request: optimized counter? #463

whyrusleeping opened this issue Dec 4, 2024 · 5 comments

Comments

@whyrusleeping
Copy link

For my application i needed a way to track (up to some maximum) the number of likes for each of a number of given post IDs, and I'm already tracking sets of likes on posts by user using roaring bitmaps here, So I implemented a thing thats a fixed size stack of bitmaps that lets me compactly store counts by post ID.

To do the adding, I have a loop that takes in the new bitmap to add in, and then does a series of Xor and AndNot calls to do the 'Add' (see here: https://github.com/whyrusleeping/fancycounter/blob/main/fancycounter.go#L95-L100 )

I'm wondering if theres an optimized way we could do this in a single call (instead of an Xor and an AndNot separately)

Thanks in advance, and thank you so much for this library in the first place!

@lemire
Copy link
Member

lemire commented Dec 4, 2024

It could be implemented within the library as part of the BSI component: https://github.com/RoaringBitmap/roaring/tree/master/BitSliceIndexing

I'm wondering if theres an optimized way we could do this in a single call (instead of an Xor and an AndNot separately)

Can you elaborate?

@guymolinari
Copy link
Contributor

guymolinari commented Dec 4, 2024 via email

@whyrusleeping
Copy link
Author

I'm not entirely sure I understand what the purpose of a BSI is.

The data structure i need is roughly a map[PostID]int to count likes per post, and a fast way to sum two of these (or add in a []PostID efficiently)

@guymolinari
Copy link
Contributor

guymolinari commented Dec 4, 2024 via email

@lemire
Copy link
Member

lemire commented Dec 4, 2024

I'm not entirely sure I understand what the purpose of a BSI is.

I cannot be certain, but it seems that what you have implemented is the same data structure as our BSI.

If that's the case, it might be a good idea to adopt our BSI and contribute to it if needed.

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

No branches or pull requests

3 participants