From 1e56b88f59d737d488891e22f2bc1c6af9193c07 Mon Sep 17 00:00:00 2001 From: HaoranYi Date: Wed, 20 Sep 2023 11:12:42 -0500 Subject: [PATCH] Update index bucket after data bucket updated (#33315) * typos * update index bucket after data bucket --------- Co-authored-by: HaoranYi --- bucket_map/src/bucket.rs | 10 ++++++---- bucket_map/src/index_entry.rs | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 9dbc3402f..daf04b449 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -498,10 +498,6 @@ impl<'b, T: Clone + Copy + PartialEq + std::fmt::Debug + 'static> Bucket { multiple_slots.set_num_slots(num_slots); MultipleSlots::set_ref_count(best_bucket, ix, ref_count); - elem.set_slot_count_enum_value( - &mut self.index, - OccupiedEnum::MultipleSlots(&multiple_slots), - ); //debug!( "DATA ALLOC {:?} {} {} {}", key, elem.data_location, best_bucket.capacity, elem_uid ); let best_bucket = &mut self.data[best_fit_bucket as usize]; best_bucket.occupy(ix, false).unwrap(); @@ -512,6 +508,12 @@ impl<'b, T: Clone + Copy + PartialEq + std::fmt::Debug + 'static> Bucket { *dest = *src; }); } + + // update index bucket after data bucket has been updated. + elem.set_slot_count_enum_value( + &mut self.index, + OccupiedEnum::MultipleSlots(&multiple_slots), + ); success = true; break; } diff --git a/bucket_map/src/index_entry.rs b/bucket_map/src/index_entry.rs index a3e2fb896..a81cb7865 100644 --- a/bucket_map/src/index_entry.rs +++ b/bucket_map/src/index_entry.rs @@ -283,7 +283,7 @@ pub(crate) union SingleElementOrMultipleSlots { /// the slot list contains a single element. No need for an entry in the data file. /// The element itself is stored in place in the index entry pub(crate) single_element: T, - /// the slot list ocntains more than one element. This contains the reference to the data file. + /// the slot list contains more than one element. This contains the reference to the data file. pub(crate) multiple_slots: MultipleSlots, } @@ -313,7 +313,7 @@ pub(crate) enum OccupiedEnum<'a, T> { MultipleSlots(&'a MultipleSlots) = OccupiedEnumTag::MultipleSlots as u8, } -/// Pack the storage offset and capacity-when-crated-pow2 fields into a single u64 +/// Pack the storage offset and capacity-when-created-pow2 fields into a single u64 #[bitfield(bits = 64)] #[repr(C)] #[derive(Debug, Default, Copy, Clone, Eq, PartialEq)]