Skip to content

Commit

Permalink
disk index: remove Option on read_value (#31023)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Apr 3, 2023
1 parent ef6b679 commit 7edef94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
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(),
});
}
}
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
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(
Expand Down
10 changes: 5 additions & 5 deletions bucket_map/src/index_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,17 @@ impl<T: Copy> IndexEntryPlaceInBucket<T> {
index_entry.set_slot_count_enum_value(value);
}

pub fn ref_count(&self, index_bucket: &BucketStorage<IndexBucket<T>>) -> RefCount {
fn ref_count(&self, index_bucket: &BucketStorage<IndexBucket<T>>) -> RefCount {
let index_entry = index_bucket.get::<IndexEntry<T>>(self.ix);
index_entry.packed_ref_count.ref_count()
}

pub fn read_value<'a>(
pub(crate) fn read_value<'a>(
&self,
index_bucket: &'a BucketStorage<IndexBucket<T>>,
data_buckets: &'a [BucketStorage<DataBucket>],
) -> 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.
Expand All @@ -315,7 +315,7 @@ impl<T: Copy> IndexEntryPlaceInBucket<T> {
}
},
self.ref_count(index_bucket),
))
)
}

pub fn new(ix: u64) -> Self {
Expand Down

0 comments on commit 7edef94

Please sign in to comment.