From e7a1e9423594cef60d8bfb2e4e8665995ef2bea1 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Mon, 3 Apr 2023 13:36:58 -0500 Subject: [PATCH] disk index: remove Option on read_value (#31023) --- bucket_map/src/bucket.rs | 8 ++++---- bucket_map/src/index_entry.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 1f9668030ab810..dcad861aa2e365 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -151,11 +151,11 @@ impl<'b, T: Clone + Copy + 'static> Bucket { let ix = IndexEntryPlaceInBucket::new(ii); let key = ix.key(&self.index); if range.map(|r| r.contains(key)).unwrap_or(true) { - let val = ix.read_value(&self.index, &self.data); + let (v, ref_count) = ix.read_value(&self.index, &self.data); result.push(BucketItem { pubkey: *key, - ref_count: ix.ref_count(&self.index), - slot_list: val.map(|(v, _ref_count)| v.to_vec()).unwrap_or_default(), + ref_count, + slot_list: v.to_vec(), }); } } @@ -264,7 +264,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket { pub fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)> { //debug!("READ_VALUE: {:?}", key); let (elem, _) = self.find_index_entry(key)?; - elem.read_value(&self.index, &self.data) + Some(elem.read_value(&self.index, &self.data)) } pub fn try_write( diff --git a/bucket_map/src/index_entry.rs b/bucket_map/src/index_entry.rs index a95acbc7ba0b5a..0c9e05f5235822 100644 --- a/bucket_map/src/index_entry.rs +++ b/bucket_map/src/index_entry.rs @@ -296,7 +296,7 @@ impl IndexEntryPlaceInBucket { index_entry.set_slot_count_enum_value(value); } - pub fn ref_count(&self, index_bucket: &BucketStorage>) -> RefCount { + fn ref_count(&self, index_bucket: &BucketStorage>) -> RefCount { let index_entry = index_bucket.get::>(self.ix); index_entry.packed_ref_count.ref_count() } @@ -305,8 +305,8 @@ impl IndexEntryPlaceInBucket { &self, index_bucket: &'a BucketStorage>, data_buckets: &'a [BucketStorage], - ) -> Option<(&'a [T], RefCount)> { - Some(( + ) -> (&'a [T], RefCount) { + ( match self.get_slot_count_enum(index_bucket) { OccupiedEnum::ZeroSlots => { // num_slots is 0. This means we don't have an actual allocation. @@ -330,7 +330,7 @@ impl IndexEntryPlaceInBucket { } }, self.ref_count(index_bucket), - )) + ) } pub fn new(ix: u64) -> Self {