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) => {
|
Ok(_result) => {
|
||||||
// everything added
|
// everything added
|
||||||
self.set_anticipated_count(0);
|
self.set_anticipated_count(0);
|
||||||
|
self.index.count.fetch_add(
|
||||||
|
count.saturating_sub(duplicates.len()) as u64,
|
||||||
|
Ordering::Relaxed,
|
||||||
|
);
|
||||||
return duplicates;
|
return duplicates;
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
|
@ -400,9 +400,14 @@ mod tests {
|
||||||
};
|
};
|
||||||
|
|
||||||
let verify = || {
|
let verify = || {
|
||||||
|
let expected_count = hash_map.read().unwrap().len();
|
||||||
let mut maps = maps
|
let mut maps = maps
|
||||||
.iter()
|
.iter()
|
||||||
.map(|map| {
|
.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![];
|
let mut r = vec![];
|
||||||
for bin in 0..map.num_buckets() {
|
for bin in 0..map.num_buckets() {
|
||||||
r.append(
|
r.append(
|
||||||
|
|
Loading…
Reference in New Issue