pub struct StorageAccessPredictor {
pub history: HashMap<String, Vec<AccessEvent>>,
}Expand description
Predicts future block access patterns from historical access sequences.
Events are stored in a bounded per-CID ring (capped at MAX_HISTORY).
The predictor derives an AccessPattern from the inter-access intervals
and computes a confidence score for each prediction.
Fields§
§history: HashMap<String, Vec<AccessEvent>>Per-CID ordered list of access events (oldest first).
Implementations§
Source§impl StorageAccessPredictor
impl StorageAccessPredictor
Sourcepub fn record(&mut self, event: AccessEvent)
pub fn record(&mut self, event: AccessEvent)
Record a new access event.
Events are appended to the per-CID history. When the history exceeds
MAX_HISTORY entries the oldest entry (index 0) is evicted.
Sourcepub fn predict(&self, cid: &str) -> PredictionResult
pub fn predict(&self, cid: &str) -> PredictionResult
Predict the access pattern for a given CID.
Returns a PredictionResult with pattern = Random and
confidence = 0.0 when no history is available, or confidence = 0.1
when only a single event has been recorded.
Sourcepub fn top_predicted(&self) -> Vec<PredictionResult>
pub fn top_predicted(&self) -> Vec<PredictionResult>
Return predictions for all tracked CIDs whose pattern is Sequential
or Repeated, sorted by descending confidence.
Sourcepub fn stats(&self) -> PredictorStats
pub fn stats(&self) -> PredictorStats
Compute aggregate statistics for the current state of the predictor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for StorageAccessPredictor
impl RefUnwindSafe for StorageAccessPredictor
impl Send for StorageAccessPredictor
impl Sync for StorageAccessPredictor
impl Unpin for StorageAccessPredictor
impl UnsafeUnpin for StorageAccessPredictor
impl UnwindSafe for StorageAccessPredictor
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