Skip to main content

ShingledForest

Struct ShingledForest 

Source
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>

Source

pub const fn shingle_size(&self) -> usize

Shingle size (equals the compile-time D).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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
Source

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
Source

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.

Source

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.

Source

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§

Source§

impl<const D: usize> Debug for ShingledForest<D>

Source§

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

Formats the value using the given formatter. Read more

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V