avoid unnecessary disk bucket data file allocation (#31659)
This commit is contained in:
parent
392e33d893
commit
bace5679a1
|
@ -402,8 +402,10 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
|
|||
data_len: usize,
|
||||
ref_count: RefCount,
|
||||
) -> Result<(), BucketMapError> {
|
||||
let num_slots = data_len as u64;
|
||||
let best_fit_bucket = MultipleSlots::data_bucket_from_num_slots(data_len as u64);
|
||||
if self.data.get(best_fit_bucket as usize).is_none() {
|
||||
let requires_data_bucket = num_slots > 1 || ref_count != 1;
|
||||
if requires_data_bucket && self.data.get(best_fit_bucket as usize).is_none() {
|
||||
// fail early if the data bucket we need doesn't exist - we don't want the index entry partially allocated
|
||||
return Err(BucketMapError::DataNoSpace((best_fit_bucket, 0)));
|
||||
}
|
||||
|
@ -420,8 +422,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
|
|||
elem_allocate.init(&mut self.index, key);
|
||||
elem_allocate
|
||||
};
|
||||
let num_slots = data_len as u64;
|
||||
if num_slots <= 1 && ref_count == 1 {
|
||||
if !requires_data_bucket {
|
||||
// new data stored should be stored in IndexEntry and NOT in data file
|
||||
// new data len is 0 or 1
|
||||
if let OccupiedEnum::MultipleSlots(multiple_slots) =
|
||||
|
|
Loading…
Reference in New Issue