Struct solana_bucket_map::bucket::Bucket
source · pub struct Bucket<T: Copy + 'static> {
drives: Arc<Vec<PathBuf>>,
pub index: BucketStorage<IndexBucketUsingBitVecBits<T>>,
random: u64,
pub data: Vec<BucketStorage<BucketWithHeader>>,
stats: Arc<BucketMapStats>,
anticipated_size: u64,
pub reallocated: Reallocated<IndexBucketUsingBitVecBits<T>, BucketWithHeader>,
at_least_one_entry_deleted: bool,
}
Fields§
§drives: Arc<Vec<PathBuf>>
§index: BucketStorage<IndexBucketUsingBitVecBits<T>>
index
random: u64
random offset for the index
data: Vec<BucketStorage<BucketWithHeader>>
storage buckets to store SlotSlice up to a power of 2 in len
stats: Arc<BucketMapStats>
§anticipated_size: u64
entries caller expects the map to need to contain.
Used as a hint for the next time we need to grow.
reallocated: Reallocated<IndexBucketUsingBitVecBits<T>, BucketWithHeader>
§at_least_one_entry_deleted: bool
set to true once any entries have been deleted from the index. Deletes indicate that there can be free slots and that the full search range must be searched for an entry.
Implementations§
source§impl<'b, T: Clone + Copy + 'static> Bucket<T>
impl<'b, T: Clone + Copy + 'static> Bucket<T>
pub fn new( drives: Arc<Vec<PathBuf>>, max_search: MaxSearch, stats: Arc<BucketMapStats>, count: Arc<AtomicU64> ) -> Self
pub fn keys(&self) -> Vec<Pubkey>
pub fn items_in_range<R>(&self, range: &Option<&R>) -> Vec<BucketItem<T>>where R: RangeBounds<Pubkey>,
pub fn find_index_entry( &self, key: &Pubkey ) -> Option<(IndexEntryPlaceInBucket<T>, u64)>
sourcefn find_index_entry_mut(
index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>,
key: &Pubkey,
random: u64
) -> Result<(Option<IndexEntryPlaceInBucket<T>>, u64), BucketMapError>
fn find_index_entry_mut( index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>, key: &Pubkey, random: u64 ) -> Result<(Option<IndexEntryPlaceInBucket<T>>, u64), BucketMapError>
find an entry for key
if entry exists, return the entry along with the index of the existing entry
if entry does not exist, return just the index of an empty entry appropriate for this key
returns (existing entry, index of the found or empty entry)
fn bucket_find_index_entry( index: &BucketStorage<IndexBucketUsingBitVecBits<T>>, key: &Pubkey, random: u64 ) -> Option<(IndexEntryPlaceInBucket<T>, u64)>
fn bucket_create_key( index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>, key: &Pubkey, random: u64, is_resizing: bool ) -> Result<u64, BucketMapError>
pub(crate) fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)>
sourcefn index_entries(
items: impl Iterator<Item = (Pubkey, T)>,
count: usize,
random: u64
) -> Vec<(u64, Pubkey, T)>
fn index_entries( items: impl Iterator<Item = (Pubkey, T)>, count: usize, random: u64 ) -> Vec<(u64, Pubkey, T)>
for each item in items
, get the hash value when hashed with random
.
Return a vec of tuples:
(hash_value, key, value)
sourcepub(crate) fn batch_insert_non_duplicates(
&mut self,
items: impl Iterator<Item = (Pubkey, T)>,
count: usize
) -> Vec<(Pubkey, T, T)>
pub(crate) fn batch_insert_non_duplicates( &mut self, items: impl Iterator<Item = (Pubkey, T)>, count: usize ) -> Vec<(Pubkey, T, T)>
insert all of items
into the index.
return duplicates
sourcepub fn batch_insert_non_duplicates_internal(
index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>,
data_buckets: &[BucketStorage<BucketWithHeader>],
reverse_sorted_entries: &mut Vec<(u64, Pubkey, T)>,
duplicates: &mut Vec<(Pubkey, T, T)>
) -> Result<(), BucketMapError>
pub fn batch_insert_non_duplicates_internal( index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>, data_buckets: &[BucketStorage<BucketWithHeader>], reverse_sorted_entries: &mut Vec<(u64, Pubkey, T)>, duplicates: &mut Vec<(Pubkey, T, T)> ) -> Result<(), BucketMapError>
sort entries
by hash value
insert as much of entries
as possible into index
.
return an error if the index needs to resize.
for every entry that already exists in index
, add it (and the value already in the index) to duplicates
pub fn try_write( &mut self, key: &Pubkey, data: impl Iterator<Item = &'b T>, data_len: usize, ref_count: RefCount ) -> Result<(), BucketMapError>
pub fn delete_key(&mut self, key: &Pubkey)
pub(crate) fn set_anticipated_count(&mut self, count: u64)
pub fn grow_index(&self, current_capacity: u64)
pub fn apply_grow_index( &mut self, index: BucketStorage<IndexBucketUsingBitVecBits<T>> )
fn elem_size() -> u64
fn add_data_bucket(&mut self, bucket: BucketStorage<BucketWithHeader>)
pub fn apply_grow_data( &mut self, ix: usize, bucket: BucketStorage<BucketWithHeader> )
sourcepub fn grow_data(&self, data_index: u64, current_capacity_pow2: u8)
pub fn grow_data(&self, data_index: u64, current_capacity_pow2: u8)
grow a data bucket The application of the new bucket is deferred until the next write lock.
fn bucket_index_ix(key: &Pubkey, random: u64) -> u64
sourcepub(crate) fn grow(&self, err: BucketMapError)
pub(crate) fn grow(&self, err: BucketMapError)
grow the appropriate piece. Note this takes an immutable ref. The actual grow is set into self.reallocated and applied later on a write lock
sourcepub fn handle_delayed_grows(&mut self)
pub fn handle_delayed_grows(&mut self)
if a bucket was resized previously with a read lock, then apply that resize now