pub struct ShingledForest<const D: usize> { /* private fields */ }Expand description
D-dim shingled wrapper over RandomCutForest — scalar-stream
input, internal ring buffer of the last D samples.
The ring buffer is stored oldest-to-newest logically but laid out
as a circular array internally — constant-time update with no
allocation. ShingledForest::current_shingle exposes the
logical shingle in read-only form (oldest-first) for diagnostics.
Implementations§
Source§impl<const D: usize> ShingledForest<D>
impl<const D: usize> ShingledForest<D>
Sourcepub const fn shingle_size(&self) -> usize
pub const fn shingle_size(&self) -> usize
Shingle size (equals the compile-time D).
Sourcepub const fn is_warmed(&self) -> bool
pub const fn is_warmed(&self) -> bool
Whether the ring buffer holds a full D-scalar window and
the forest has received at least one shingle.
Sourcepub fn forest(&self) -> &RandomCutForest<D>
pub fn forest(&self) -> &RandomCutForest<D>
Immutable view of the underlying bare forest — use this to
inspect tree state, read metrics, or route through the
RandomCutForest::forensic_baseline / attribution
helpers on the already-shingled last point.
Sourcepub fn forest_mut(&mut self) -> &mut RandomCutForest<D>
pub fn forest_mut(&mut self) -> &mut RandomCutForest<D>
Mutable escape hatch — handy for bootstrap replay
(RandomCutForest::bootstrap) when the caller has
pre-shingled their warm-up corpus.
Sourcepub fn current_shingle(&self) -> Option<[f64; D]>
pub fn current_shingle(&self) -> Option<[f64; D]>
Snapshot the current shingle in logical order (oldest-first).
Returns None while the ring is still partially empty.
Sourcepub fn update_scalar(&mut self, value: f64) -> RcfResult<bool>
pub fn update_scalar(&mut self, value: f64) -> RcfResult<bool>
Fold value into the ring buffer; once the ring is full,
forward the shingled window to the forest. Returns true
when the shingle was submitted to the forest (i.e. the ring
was full before the call).
§Errors
RcfError::NaNValueon non-finitevalue.- Propagates
RandomCutForest::updatefailures once the shingle is submitted.
Sourcepub fn score_scalar(&self, value: f64) -> RcfResult<AnomalyScore>
pub fn score_scalar(&self, value: f64) -> RcfResult<AnomalyScore>
Score value against the frozen forest without folding
it into the ring buffer. The query uses the current shingle
with value appended as the newest slot — matches what a
subsequent Self::update_scalar would submit.
§Errors
RcfError::NaNValueon non-finitevalue.RcfError::EmptyForestbefore the ring buffer is full or the forest has not yet received its first update.- Propagates
RandomCutForest::scorefailures.
Sourcepub fn attribution_scalar(&self, value: f64) -> RcfResult<DiVector>
pub fn attribution_scalar(&self, value: f64) -> RcfResult<DiVector>
Attribution on the shingle formed by appending value to
the current ring. Returns a D-dim DiVector where each
dim is a lag index (0 = oldest, D-1 = newest / value).
§Errors
Same as Self::score_scalar.
Sourcepub fn score_codisp_stateless_scalar(
&self,
value: f64,
) -> RcfResult<AnomalyScore>
pub fn score_codisp_stateless_scalar( &self, value: f64, ) -> RcfResult<AnomalyScore>
Stateless codisp on the shingle formed with value appended.
Non-mutating — preserves the frozen-baseline contract across
long streams. Prefer this over the mutating score_codisp
path for shingled forensic replay.
§Errors
Same as Self::score_scalar.
Sourcepub fn reset_ring(&mut self)
pub fn reset_ring(&mut self)
Drop the ring buffer and reset the warm-up flag; the underlying forest is not reset — callers who want a full state wipe should rebuild.
Trait Implementations§
Auto Trait Implementations§
impl<const D: usize> Freeze for ShingledForest<D>
impl<const D: usize> !RefUnwindSafe for ShingledForest<D>
impl<const D: usize> Send for ShingledForest<D>
impl<const D: usize> Sync for ShingledForest<D>
impl<const D: usize> Unpin for ShingledForest<D>
impl<const D: usize> UnsafeUnpin for ShingledForest<D>
impl<const D: usize> !UnwindSafe for ShingledForest<D>
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> 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