Skip to content

Commit

Permalink
remove <T> from IndexEntryPlaceInBucket
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Mar 29, 2023
1 parent 9f7daf8 commit eaa712c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
8 changes: 4 additions & 4 deletions bucket_map/src/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
result
}

pub fn find_index_entry(&self, key: &Pubkey) -> Option<(IndexEntryPlaceInBucket<T>, u64)> {
pub fn find_index_entry(&self, key: &Pubkey) -> Option<(IndexEntryPlaceInBucket, u64)> {
Self::bucket_find_index_entry(&self.index, key, self.random)
}

Expand All @@ -168,7 +168,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
index: &mut BucketStorage<IndexBucket>,
key: &Pubkey,
random: u64,
) -> Result<(Option<IndexEntryPlaceInBucket<T>>, u64), BucketMapError> {
) -> Result<(Option<IndexEntryPlaceInBucket>, u64), BucketMapError> {
let ix = Self::bucket_index_ix(index, key, random);
let mut first_free = None;
let mut m = Measure::start("bucket_find_index_entry_mut");
Expand Down Expand Up @@ -207,7 +207,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
index: &BucketStorage<IndexBucket>,
key: &Pubkey,
random: u64,
) -> Option<(IndexEntryPlaceInBucket<T>, u64)> {
) -> Option<(IndexEntryPlaceInBucket, u64)> {
let ix = Self::bucket_index_ix(index, key, random);
for i in ix..ix + index.max_search() {
let ii = i % index.capacity();
Expand Down Expand Up @@ -238,7 +238,7 @@ impl<'b, T: Clone + Copy + 'static> Bucket<T> {
index.occupy(ii, is_resizing).unwrap();
// These fields will be overwritten after allocation by callers.
// Since this part of the mmapped file could have previously been used by someone else, there can be garbage here.
IndexEntryPlaceInBucket::<T>::new(ii).init(index, key);
IndexEntryPlaceInBucket::new(ii).init(index, key);
//debug!( "INDEX ALLOC {:?} {} {} {}", key, ii, index.capacity, elem_uid );
m.stop();
index
Expand Down
16 changes: 6 additions & 10 deletions bucket_map/src/index_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use {
bv::BitVec,
modular_bitfield::prelude::*,
solana_sdk::{clock::Slot, pubkey::Pubkey},
std::{fmt::Debug, marker::PhantomData},
std::fmt::Debug,
};

/// in use/occupied
Expand Down Expand Up @@ -57,9 +57,8 @@ pub type IndexBucket = BucketWithBitVec;

/// contains the index of an entry in the index bucket.
/// This type allows us to call methods to interact with the index entry on this type.
pub struct IndexEntryPlaceInBucket<T: 'static> {
pub struct IndexEntryPlaceInBucket {
pub ix: u64,
_phantom: PhantomData<T>,
}

#[repr(C)]
Expand Down Expand Up @@ -99,7 +98,7 @@ impl IndexEntry {
}
}

impl<T> IndexEntryPlaceInBucket<T> {
impl IndexEntryPlaceInBucket {
pub fn init(&self, index_bucket: &mut BucketStorage<IndexBucket>, pubkey: &Pubkey) {
let index_entry = index_bucket.get_mut::<IndexEntry>(self.ix);
index_entry.key = *pubkey;
Expand Down Expand Up @@ -169,7 +168,7 @@ impl<T> IndexEntryPlaceInBucket<T> {
.capacity_when_created_pow2())
}

pub fn read_value<'a>(
pub fn read_value<'a, T>(
&self,
index_bucket: &BucketStorage<IndexBucket>,
data_buckets: &'a [BucketStorage<DataBucket>],
Expand All @@ -189,10 +188,7 @@ impl<T> IndexEntryPlaceInBucket<T> {
}

pub fn new(ix: u64) -> Self {
Self {
ix,
_phantom: PhantomData,
}
Self { ix }
}

pub fn key<'a>(&self, index_bucket: &'a BucketStorage<IndexBucket>) -> &'a Pubkey {
Expand Down Expand Up @@ -273,7 +269,7 @@ mod tests {
BucketStorage::<IndexBucket>::new(Arc::new(paths), 1, 1, 1, Arc::default(), Arc::default())
}

fn index_entry_for_testing() -> (BucketStorage<IndexBucket>, IndexEntryPlaceInBucket<u64>) {
fn index_entry_for_testing() -> (BucketStorage<IndexBucket>, IndexEntryPlaceInBucket) {
(index_bucket_for_testing(), IndexEntryPlaceInBucket::new(0))
}

Expand Down

0 comments on commit eaa712c

Please sign in to comment.