pub struct StorageHeatmapTracker {
pub entries: HashMap<String, HeatEntry>,
pub decay_factor: f64,
pub current_tick: u64,
}Expand description
Tracks per-block access heat scores over time using exponential decay.
Fields§
§entries: HashMap<String, HeatEntry>All tracked entries, keyed by CID.
decay_factor: f64Per-tick decay factor (e.g. 0.9 means score *= 0.9 each tick).
current_tick: u64Current logical time tick.
Implementations§
Source§impl StorageHeatmapTracker
impl StorageHeatmapTracker
Sourcepub fn new(decay_factor: f64) -> Self
pub fn new(decay_factor: f64) -> Self
Create a new tracker with the given per-tick decay factor.
Sourcepub fn record_access(&mut self, cid: &str, heat_gain: f64)
pub fn record_access(&mut self, cid: &str, heat_gain: f64)
Record an access to cid, adding heat_gain to its score.
If the entry already exists, lazy decay is applied for the ticks that
elapsed since the last access before adding the gain. If the entry is
new it is created with score = heat_gain.
Sourcepub fn advance_tick(&mut self)
pub fn advance_tick(&mut self)
Advance the logical clock by one tick.
Decay is applied lazily on the next access; use decay_all to force
an eager decay pass across all entries.
Sourcepub fn top_k(&self, k: usize) -> Vec<&HeatEntry>
pub fn top_k(&self, k: usize) -> Vec<&HeatEntry>
Return the top-k entries by score, in descending order.
Sourcepub fn evict_cold(&mut self, min_score: f64) -> usize
pub fn evict_cold(&mut self, min_score: f64) -> usize
Remove all entries whose score is strictly less than min_score.
Returns the number of entries removed.
Sourcepub fn stats(&self) -> HeatmapStats
pub fn stats(&self) -> HeatmapStats
Compute aggregate statistics over all current entries.
Auto Trait Implementations§
impl Freeze for StorageHeatmapTracker
impl RefUnwindSafe for StorageHeatmapTracker
impl Send for StorageHeatmapTracker
impl Sync for StorageHeatmapTracker
impl Unpin for StorageHeatmapTracker
impl UnsafeUnpin for StorageHeatmapTracker
impl UnwindSafe for StorageHeatmapTracker
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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