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>

source

pub fn new( drives: Arc<Vec<PathBuf>>, max_search: MaxSearch, stats: Arc<BucketMapStats>, count: Arc<AtomicU64> ) -> Self

source

pub fn keys(&self) -> Vec<Pubkey>

source

pub fn items_in_range<R>(&self, range: &Option<&R>) -> Vec<BucketItem<T>>where R: RangeBounds<Pubkey>,

source

pub fn find_index_entry( &self, key: &Pubkey ) -> Option<(IndexEntryPlaceInBucket<T>, u64)>

source

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)

source

fn bucket_find_index_entry( index: &BucketStorage<IndexBucketUsingBitVecBits<T>>, key: &Pubkey, random: u64 ) -> Option<(IndexEntryPlaceInBucket<T>, u64)>

source

fn bucket_create_key( index: &mut BucketStorage<IndexBucketUsingBitVecBits<T>>, key: &Pubkey, random: u64, is_resizing: bool ) -> Result<u64, BucketMapError>

source

pub(crate) fn read_value(&self, key: &Pubkey) -> Option<(&[T], RefCount)>

source

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)

source

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

source

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

source

pub fn try_write( &mut self, key: &Pubkey, data: impl Iterator<Item = &'b T>, data_len: usize, ref_count: RefCount ) -> Result<(), BucketMapError>

source

pub fn delete_key(&mut self, key: &Pubkey)

source

pub(crate) fn set_anticipated_count(&mut self, count: u64)

source

pub fn grow_index(&self, current_capacity: u64)

source

pub fn apply_grow_index( &mut self, index: BucketStorage<IndexBucketUsingBitVecBits<T>> )

source

fn elem_size() -> u64

source

fn add_data_bucket(&mut self, bucket: BucketStorage<BucketWithHeader>)

source

pub fn apply_grow_data( &mut self, ix: usize, bucket: BucketStorage<BucketWithHeader> )

source

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.

source

fn bucket_index_ix(key: &Pubkey, random: u64) -> u64

source

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

source

pub fn handle_delayed_grows(&mut self)

if a bucket was resized previously with a read lock, then apply that resize now

source

pub fn insert(&mut self, key: &Pubkey, value: (&[T], RefCount))

source

pub fn update<F>(&mut self, key: &Pubkey, updatefn: F)where F: FnMut(Option<(&[T], RefCount)>) -> Option<(Vec<T>, RefCount)>,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Bucket<T>where T: RefUnwindSafe,

§

impl<T> Send for Bucket<T>where T: Sync,

§

impl<T> Sync for Bucket<T>where T: Sync,

§

impl<T> Unpin for Bucket<T>

§

impl<T> UnwindSafe for Bucket<T>where T: RefUnwindSafe,

Blanket Implementations§

§

impl<T> AbiExample for T

§

default fn example() -> T

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V