-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Journaling bloom filter crate in util #2395
Conversation
pub hash_functions: u32, | ||
pub entries: Vec<(usize, u64)>, | ||
} | ||
|
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.
tests could be in a separate tests
module
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.
done, though it's not much of a convention
Needs the license from the original work: https://github.com/jedisct1/rust-bloom-filter/blob/master/LICENSE Actually, I think we might need this license in our distribution if we use this project in any form if statically linking it in counts as a binary distribution. (is this compatible with our GPL? @tjsaw) |
@rphmeier |
Changes Unknown when pulling 59c0551 on bloom-crate into * on master*. |
This is BSD-2-Clause. Pretty sure it is compatible |
} | ||
|
||
pub fn drain(&mut self) -> Vec<(usize, u64)> { | ||
let journal = self.journal.drain().collect::<Vec<usize>>(); |
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.
No need for a temporary vector here
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.
not a simple change since drain holds &mut
ref to self
but i will try something
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.
let journal = mem::replace(&self.journal, HashMap::new()).into_iter()
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.
or explicitly borrow the other field of self outside of the closure so the closure doesn't capture self
.
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.
done
journal.iter().map(|idx| (*idx, self.elems[*idx])).collect::<Vec<(usize, u64)>>() | ||
} | ||
|
||
pub fn how_full(&self) -> f64 { |
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.
Should be called "saturation" or something like that
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.
done
|
||
/// Initializes bloom filter from saved state | ||
pub fn from_parts(parts: &[u64], k_num: u32) -> Bloom { | ||
let bitmap_size = parts.len()*8; |
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.
spacing around '*'
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.
done
Changes Unknown when pulling 1863049 on bloom-crate into * on master*. |
Changes Unknown when pulling 1863049 on bloom-crate into * on master*. |
No description provided.