Struct solana_bucket_map::bucket_storage::BucketStorage
source · pub struct BucketStorage<O: BucketOccupied> {
path: PathBuf,
mmap: MmapMut,
pub cell_size: u64,
pub count: Arc<AtomicU64>,
pub stats: Arc<BucketStats>,
pub max_search: MaxSearch,
pub contents: O,
}
Fields§
§path: PathBuf
§mmap: MmapMut
§cell_size: u64
§count: Arc<AtomicU64>
§stats: Arc<BucketStats>
§max_search: MaxSearch
§contents: O
Implementations§
source§impl<O: BucketOccupied> BucketStorage<O>
impl<O: BucketOccupied> BucketStorage<O>
sourcepub fn new_with_capacity(
drives: Arc<Vec<PathBuf>>,
num_elems: u64,
elem_size: u64,
capacity: Capacity,
max_search: MaxSearch,
stats: Arc<BucketStats>,
count: Arc<AtomicU64>
) -> Self
pub fn new_with_capacity( drives: Arc<Vec<PathBuf>>, num_elems: u64, elem_size: u64, capacity: Capacity, max_search: MaxSearch, stats: Arc<BucketStats>, count: Arc<AtomicU64> ) -> Self
allocate a bucket of at least capacity
elements.
if capacity can be random, more may be allocated to fill the last page.
fn allocate_to_fill_page(capacity: &mut Capacity, cell_size: u64) -> u64
pub fn max_search(&self) -> u64
pub fn new( drives: Arc<Vec<PathBuf>>, num_elems: u64, elem_size: u64, max_search: MaxSearch, stats: Arc<BucketStats>, count: Arc<AtomicU64> ) -> Self
pub(crate) fn copying_entry(&mut self, ix_new: u64, other: &Self, ix_old: u64)
sourcepub fn is_free(&self, ix: u64) -> bool
pub fn is_free(&self, ix: u64) -> bool
true if the entry at index ‘ix’ is free (as opposed to being occupied)
sourcepub fn occupy(
&mut self,
ix: u64,
is_resizing: bool
) -> Result<(), BucketStorageError>
pub fn occupy( &mut self, ix: u64, is_resizing: bool ) -> Result<(), BucketStorageError>
‘is_resizing’ true if caller is resizing the index (so don’t increment count) ‘is_resizing’ false if caller is adding an item to the index (so increment count)
pub fn free(&mut self, ix: u64)
fn get_start_offset_with_header(&self, ix: u64) -> usize
fn get_start_offset(&self, ix: u64, header: IncludeHeader) -> usize
pub(crate) fn get_header<T>(&self, ix: u64) -> &T
pub(crate) fn get_header_mut<T>(&mut self, ix: u64) -> &mut T
pub(crate) fn get<T>(&self, ix: u64) -> &T
pub(crate) fn get_mut<T>(&mut self, ix: u64) -> &mut T
pub(crate) fn get_mut_from_parts<T>(item_slice: &mut [u8]) -> &mut T
pub(crate) fn get_from_parts<T>(item_slice: &[u8]) -> &T
pub(crate) fn get_cell_slice<T>( &self, ix: u64, len: u64, header: IncludeHeader ) -> &[T]
pub(crate) fn get_mut_cell_slice<T>( &mut self, ix: u64, len: u64, header: IncludeHeader ) -> &mut [T]
sourcefn new_map(
drives: &[PathBuf],
bytes: u64,
stats: &BucketStats
) -> (MmapMut, PathBuf)
fn new_map( drives: &[PathBuf], bytes: u64, stats: &BucketStats ) -> (MmapMut, PathBuf)
allocate a new memory mapped file of size bytes
on one of drives
sourcefn copy_contents(&mut self, old_bucket: &Self)
fn copy_contents(&mut self, old_bucket: &Self)
copy contents from ‘old_bucket’ to ‘self’ This is used by data buckets
pub fn update_max_size(&self)
sourcepub fn new_resized(
drives: &Arc<Vec<PathBuf>>,
max_search: MaxSearch,
bucket: Option<&Self>,
capacity: Capacity,
num_elems: u64,
elem_size: u64,
stats: &Arc<BucketStats>
) -> Self
pub fn new_resized( drives: &Arc<Vec<PathBuf>>, max_search: MaxSearch, bucket: Option<&Self>, capacity: Capacity, num_elems: u64, elem_size: u64, stats: &Arc<BucketStats> ) -> Self
allocate a new bucket, copying data from ‘bucket’
sourcepub(crate) fn capacity_bytes(&self) -> u64
pub(crate) fn capacity_bytes(&self) -> u64
Return the number of bytes currently allocated
Trait Implementations§
source§impl<O: BucketOccupied> Drop for BucketStorage<O>
impl<O: BucketOccupied> Drop for BucketStorage<O>
Auto Trait Implementations§
impl<O> RefUnwindSafe for BucketStorage<O>where O: RefUnwindSafe,
impl<O> Send for BucketStorage<O>where O: Send,
impl<O> Sync for BucketStorage<O>where O: Sync,
impl<O> Unpin for BucketStorage<O>where O: Unpin,
impl<O> UnwindSafe for BucketStorage<O>where O: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more