Update index bucket after data bucket updated (#33315)

* typos

* update index bucket after data bucket

---------

Co-authored-by: HaoranYi <haoran.yi@solana.com>
This commit is contained in:
HaoranYi 2023-09-20 11:12:42 -05:00 committed by GitHub
parent 5f58d2dd4a
commit 1e56b88f59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View File

@ -498,10 +498,6 @@ impl<'b, T: Clone + Copy + PartialEq + std::fmt::Debug + 'static> Bucket<T> {
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<T> {
*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;
}

View File

@ -283,7 +283,7 @@ pub(crate) union SingleElementOrMultipleSlots<T: Clone + Copy> {
/// 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)]