Skip to content

Commit 5b88371

Browse files
committed
fix flaky test
1 parent 90ac5ce commit 5b88371

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/sketch.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ fn uint64_to_base10_slice(n: u64) -> Vec<i32> {
121121

122122
#[cfg(test)]
123123
mod tests {
124-
use std::{
125-
collections::HashMap,
126-
hash::{BuildHasher, RandomState},
127-
};
124+
use std::collections::HashMap;
125+
126+
use ahash::RandomState;
128127

129128
use super::CountMinSketch;
130129

@@ -135,7 +134,7 @@ mod tests {
135134
assert_eq!(sketch.block_mask, 2047);
136135
assert_eq!(sketch.sample_size, 163840);
137136

138-
let hasher = RandomState::new();
137+
let hasher = RandomState::with_seeds(9, 0, 7, 2);
139138
let mut failed = 0;
140139
for i in 0..8000 {
141140
let key = format!("foo:bar:{}", i);
@@ -172,7 +171,7 @@ mod tests {
172171
*i = !0;
173172
}
174173
sketch.additions = 100000;
175-
let hasher = RandomState::new();
174+
let hasher = RandomState::with_seeds(9, 0, 7, 2);
176175
let h = hasher.hash_one("foo");
177176
assert_eq!(sketch.estimate(h), 15);
178177
sketch.reset();
@@ -188,7 +187,7 @@ mod tests {
188187
#[test]
189188
fn test_sketch_reset_addition() {
190189
let mut sketch = CountMinSketch::new(500);
191-
let hasher = RandomState::new();
190+
let hasher = RandomState::with_seeds(9, 0, 7, 2);
192191
let mut counts = HashMap::new();
193192
for i in 0..5 {
194193
let key = format!("foo:bar:{}", i);
@@ -235,7 +234,7 @@ mod tests {
235234
#[test]
236235
fn test_sketch_heavy_hitters() {
237236
let mut sketch = CountMinSketch::new(512);
238-
let hasher = RandomState::new();
237+
let hasher = RandomState::with_seeds(9, 0, 7, 2);
239238

240239
for i in 100..100000 {
241240
let h = hasher.hash_one(format!("k:{}", i));

0 commit comments

Comments
 (0)