Using DefaultHasher instead of SipHasher
This commit is contained in:
parent
b2da168ff2
commit
5aadda95c3
@ -17,7 +17,8 @@
|
||||
use std::cmp;
|
||||
use std::mem;
|
||||
use std::f64;
|
||||
use std::hash::{Hash, Hasher, SipHasher};
|
||||
use std::hash::{Hash, Hasher, BuildHasher};
|
||||
use std::collections::hash_map::RandomState;
|
||||
use std::collections::HashSet;
|
||||
|
||||
/// BitVec structure with journalling
|
||||
@ -73,7 +74,7 @@ pub struct Bloom {
|
||||
bitmap: BitVecJournal,
|
||||
bitmap_bits: u64,
|
||||
k_num: u32,
|
||||
sips: [SipHasher; 2],
|
||||
sips: [RandomState; 2],
|
||||
}
|
||||
|
||||
impl Bloom {
|
||||
@ -85,7 +86,7 @@ impl Bloom {
|
||||
let bitmap_bits = (bitmap_size as u64) * 8u64;
|
||||
let k_num = Bloom::optimal_k_num(bitmap_bits, items_count);
|
||||
let bitmap = BitVecJournal::new(bitmap_bits as usize);
|
||||
let sips = [Bloom::sip_new(), Bloom::sip_new()];
|
||||
let sips = [RandomState::default(), RandomState::default()];
|
||||
Bloom {
|
||||
bitmap: bitmap,
|
||||
bitmap_bits: bitmap_bits,
|
||||
@ -99,7 +100,7 @@ impl Bloom {
|
||||
let bitmap_size = parts.len() * 8;
|
||||
let bitmap_bits = (bitmap_size as u64) * 8u64;
|
||||
let bitmap = BitVecJournal::from_parts(parts);
|
||||
let sips = [Bloom::sip_new(), Bloom::sip_new()];
|
||||
let sips = [RandomState::default(), RandomState::default()];
|
||||
Bloom {
|
||||
bitmap: bitmap,
|
||||
bitmap_bits: bitmap_bits,
|
||||
@ -174,8 +175,8 @@ impl Bloom {
|
||||
where T: Hash
|
||||
{
|
||||
if k_i < 2 {
|
||||
let sip = &mut self.sips[k_i as usize].clone();
|
||||
item.hash(sip);
|
||||
let mut sip = self.sips[k_i as usize].build_hasher();
|
||||
item.hash(&mut sip);
|
||||
let hash = sip.finish();
|
||||
hashes[k_i as usize] = hash;
|
||||
hash
|
||||
@ -184,10 +185,6 @@ impl Bloom {
|
||||
}
|
||||
}
|
||||
|
||||
fn sip_new() -> SipHasher {
|
||||
SipHasher::new()
|
||||
}
|
||||
|
||||
/// Drains the bloom journal returning the updated bloom part
|
||||
pub fn drain_journal(&mut self) -> BloomJournal {
|
||||
BloomJournal {
|
||||
|
Loading…
Reference in New Issue
Block a user