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

Or and And operations for bitvectors rrr_vector or sd_vector #329

Open
abhijitiitr opened this issue Jun 8, 2016 · 2 comments
Open

Or and And operations for bitvectors rrr_vector or sd_vector #329

abhijitiitr opened this issue Jun 8, 2016 · 2 comments

Comments

@abhijitiitr
Copy link

This is a theoretical question related to bitwise operations on compressed bitvectors. Lucene and other search engines use compressed bitmaps or roaring bitmaps to compute the OR between two representations of bitvectors, while also exploiting SIMD instructions for computing the results.

Is there a similar mechanism in the library to intersect or compute the unions of compressed bitvectors rrr_vector and sd_vector? If not, can it be done? Can you direct me towards the academic literature concerning the bitwise operations on succinct bitvectors.

@jltsiren
Copy link
Contributor

jltsiren commented Jun 9, 2016

I'm not aware of any literature on the topic.

With rrr_vector, the best idea is probably to decompress the bitvector one block at a time, do the operations with the decompressed blocks, and then compress the results if needed. Decompressing a block takes a similar amount of effort as extracting a single bit. rrr_vector::get_int() already implements something like that.

The best you can do with an sd_vector is an interator that lists the positions containing 1-bits. A select(i) query is implemented as

low[i - 1] + ((high_1_select(i) + 1 - i) << wl)

The lower wl bits of the positions are stored in array low, while the differences between the integers represented by the high-order bits are encoded in unary in uncompressed bitvector high. Because bitvector high is guaranteed to be dense, you can just count the number of 0-bits between successive 1-bits in high to update the high-order bits for the next position.

@abhijitiitr
Copy link
Author

Thanks for your response @jltsiren

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

2 participants