Skip to content

Commit

Permalink
disk index: correctly keep track of count during batch add
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Apr 10, 2023
1 parent 861bca8 commit da461ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 5 additions & 0 deletions bucket_map/src/bucket_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit da461ca

Please sign in to comment.