Skip to main content

MemoryIndex

Struct MemoryIndex 

Source
pub struct MemoryIndex { /* private fields */ }
Expand description

Canonical in-memory IndexBackend: a flat map from block identity to residency. This is the reference backend and the baseline that persistent backends (Holt/ART, RocksDB/LSM, filesystem) are compared against in Experiment mode. It reports bytes_written = 0 because nothing is persisted.

Implementations§

Source§

impl MemoryIndex

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl Debug for MemoryIndex

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryIndex

Source§

fn default() -> MemoryIndex

Returns the “default value” for a type. Read more
Source§

impl IndexBackend for MemoryIndex

Source§

fn name(&self) -> &str

Stable backend name for reports (for example “memory”, “holt”, “rocksdb”).
Source§

fn put(&mut self, residency: CacheResidency)

Insert or update a residency record for a block on a worker/tier.
Source§

fn locate(&self, key: &KvBlockKey) -> Vec<CacheResidency>

Every residency for an exact block identity. A block may be resident on several workers or tiers at once.
Source§

fn prefix_scan( &self, scope: &IdentityScope, prefix_hash: &str, ) -> Vec<CacheResidency>

Identity-aware prefix scan: residencies whose block belongs to scope and whose prefix_hash equals prefix_hash. This is the lookup where radix/ART backends are expected to beat flat maps and LSM stores.
Source§

fn remove_block( &mut self, scope: &IdentityScope, worker_id: &str, block_hash: &str, ) -> usize

Remove a single block (by content hash, within an identity scope) from a worker. Returns the number of residency records removed.
Source§

fn clear_worker(&mut self, worker_id: &str)

Drop everything resident on one worker/engine (for AllBlocksCleared or worker loss).
Source§

fn clear(&mut self)

Drop the entire index.
Source§

fn snapshot(&self) -> Vec<CacheResidency>

Full residency snapshot, for debugging and for routers that consume a slice of residency.
Source§

fn len(&self) -> usize

Number of residency records currently held.
Source§

fn metrics(&self) -> IndexMetrics

Comparable backend metrics (see IndexMetrics). The default derives resident_blocks/resident_bytes from a snapshot; persistent backends should override to also report bytes_written and counters.
Source§

fn is_empty(&self) -> bool

Source§

fn persistent(&self) -> bool

Whether this backend persists residency across process restarts. The in-memory reference backend returns false; Holt (ART), RocksDB (LSM), and filesystem backends return true. Drives recovery experiments and is surfaced in reports.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.