pub struct InMemAccountsIndex<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> {
pub cache_ranges_held: RwLock<Vec<RangeInclusive<Pubkey>>>,
/* private fields */
}
Fields§
§cache_ranges_held: RwLock<Vec<RangeInclusive<Pubkey>>>
Implementations§
source§impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T, U>
impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> InMemAccountsIndex<T, U>
pub fn new(storage: &Arc<BucketMapHolder<T, U>>, bin: usize) -> Self
sourcepub fn shrink_to_fit(&self)
pub fn shrink_to_fit(&self)
Release entire in-mem hashmap to free all memory associated with it. Idea is that during startup we needed a larger map than we need during runtime. When using disk-buckets, in-mem index grows over time with dynamic use and then shrinks, in theory back to 0.
pub fn items<R>(&self, range: &R) -> Vec<(Pubkey, Arc<AccountMapEntryInner<T>>)>
pub fn keys(&self) -> Vec<Pubkey>
sourcepub fn get(&self, pubkey: &Pubkey) -> Option<Arc<AccountMapEntryInner<T>>>
pub fn get(&self, pubkey: &Pubkey) -> Option<Arc<AccountMapEntryInner<T>>>
lookup ‘pubkey’ in index (in mem or on disk)
sourcepub fn get_internal<RT>(
&self,
pubkey: &Pubkey,
callback: impl for<'a> FnOnce(Option<&Arc<AccountMapEntryInner<T>>>) -> (bool, RT),
) -> RT
pub fn get_internal<RT>( &self, pubkey: &Pubkey, callback: impl for<'a> FnOnce(Option<&Arc<AccountMapEntryInner<T>>>) -> (bool, RT), ) -> RT
lookup ‘pubkey’ in index (in_mem or disk). call ‘callback’ whether found or not
pub fn remove_if_slot_list_empty(&self, pubkey: Pubkey) -> bool
pub fn slot_list_mut<RT>( &self, pubkey: &Pubkey, user: impl for<'a> FnOnce(&mut RwLockWriteGuard<'a, SlotList<T>>) -> RT, ) -> Option<RT>
pub fn upsert( &self, pubkey: &Pubkey, new_value: PreAllocatedAccountMapEntry<T>, other_slot: Option<Slot>, reclaims: &mut SlotList<T>, reclaim: UpsertReclaim, )
sourcepub fn lock_and_update_slot_list(
current: &AccountMapEntryInner<T>,
new_value: (Slot, T),
other_slot: Option<Slot>,
reclaims: &mut SlotList<T>,
reclaim: UpsertReclaim,
) -> usize
pub fn lock_and_update_slot_list( current: &AccountMapEntryInner<T>, new_value: (Slot, T), other_slot: Option<Slot>, reclaims: &mut SlotList<T>, reclaim: UpsertReclaim, ) -> usize
Try to update an item in the slot list the given slot
If an item for the slot
already exists in the list, remove the older item, add it to reclaims
, and insert
the new item.
if ‘other_slot’ is some, then also remove any entries in the slot list that are at ‘other_slot’
return resulting len of slot list
pub fn len_for_stats(&self) -> usize
sourcepub fn startup_insert_only(
&self,
items: impl Iterator<Item = (Pubkey, (Slot, T))>,
)
pub fn startup_insert_only( &self, items: impl Iterator<Item = (Pubkey, (Slot, T))>, )
Queue up these insertions for when the flush thread is dealing with this bin. This is very fast and requires no lookups or disk access.
pub fn insert_new_entry_if_missing_with_lock( &self, pubkey: Pubkey, new_entry: PreAllocatedAccountMapEntry<T>, ) -> InsertNewEntryResults
sourcepub fn hold_range_in_memory<R>(&self, range: &R, start_holding: bool)
pub fn hold_range_in_memory<R>(&self, range: &R, start_holding: bool)
if ‘start_holding’=true, then: at the end of this function, cache_ranges_held will be updated to contain ‘range’ and all pubkeys in that range will be in the in-mem cache if ‘start_holding’=false, then: ‘range’ will be removed from cache_ranges_held and all pubkeys will be eligible for being removed from in-mem cache in the bg if no other range is holding them Any in-process flush will be aborted when it gets to evicting items from in-mem.
pub fn flush(&self, can_advance_age: bool)
sourcepub fn populate_and_retrieve_duplicate_keys_from_startup(
&self,
) -> Vec<(Slot, Pubkey)>
pub fn populate_and_retrieve_duplicate_keys_from_startup( &self, ) -> Vec<(Slot, Pubkey)>
pull out all duplicate pubkeys from ‘startup_info’ duplicate pubkeys have a slot list with len > 1 These were collected for this bin when we did batch inserts in the bg flush threads. Insert these into the in-mem index, then return the duplicate (Slot, Pubkey)
pub fn stats(&self) -> &BucketMapHolderStats
pub fn update_time_stat(stat: &AtomicU64, m: Measure)
Trait Implementations§
source§impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Debug for InMemAccountsIndex<T, U>
impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Debug for InMemAccountsIndex<T, U>
Auto Trait Implementations§
impl<T, U> !Freeze for InMemAccountsIndex<T, U>
impl<T, U> RefUnwindSafe for InMemAccountsIndex<T, U>where
T: RefUnwindSafe,
impl<T, U> Send for InMemAccountsIndex<T, U>
impl<T, U> Sync for InMemAccountsIndex<T, U>
impl<T, U> Unpin for InMemAccountsIndex<T, U>
impl<T, U> UnwindSafe for InMemAccountsIndex<T, U>where
T: RefUnwindSafe,
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more