jedisct1 / rust-bloom-filter

A fast Bloom filter implementation in Rust
BSD 2-Clause "Simplified" License
235 stars 51 forks source link

Supporting defragmentation on the Bloom structure #47

Open KarthikSubbarao opened 2 weeks ago

KarthikSubbarao commented 2 weeks ago

We have a use case requiring support of defragmentation on the Bloom structure.

The only dynamic / heap allocated block within the Bloom structure is bit_vec: BitVec.

During a defragmentation cycle, we can check if an allocated block needs to be defragmented by providing a pointer to it. In case of Bloom, we will have to provide a pointer to the overall Bloom structure and the underneath bit_vec.

If defragmentation is needed, we will have to re-allocate these two blocks of memory.

pub struct Bloom<T: ?Sized> {
    bit_vec: BitVec,
    bitmap_bits: u64,
    k_num: u32,
    sips: [SipHasher13; 2],
    _phantom: PhantomData<T>,
}

To help with this, could we expose the bit_vec through an function or any alternative approach?

jedisct1 commented 2 weeks ago

bit_vec is an internal implementation detail.

But public functions to support defragmentation can be added.

Would you be able to contribute this?