Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk index: correctly keep track of count during batch add #31133

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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