disk index: correctly keep track of count during batch add (#31133)
This commit is contained in:
parent
861bca87f9
commit
4f0adcde89
|
@ -329,6 +329,10 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
|
|||
Ok(_result) => {
|
||||
// everything added
|
||||
self.set_anticipated_count(0);
|
||||
self.index.count.fetch_add(
|
||||
count.saturating_sub(duplicates.len()) as u64,
|
||||
Ordering::Relaxed,
|
||||
);
|
||||
return duplicates;
|
||||
}
|
||||
Err(error) => {
|
||||
|
|
|
@ -400,9 +400,14 @@ mod tests {
|
|||
};
|
||||
|
||||
let verify = || {
|
||||
let expected_count = hash_map.read().unwrap().len();
|
||||
let mut maps = maps
|
||||
.iter()
|
||||
.map(|map| {
|
||||
let total_entries = (0..map.num_buckets())
|
||||
.map(|bucket| map.get_bucket_from_index(bucket).bucket_len() as usize)
|
||||
.sum::<usize>();
|
||||
assert_eq!(total_entries, expected_count);
|
||||
let mut r = vec![];
|
||||
for bin in 0..map.num_buckets() {
|
||||
r.append(
|
||||
|
|
Loading…
Reference in New Issue