Skip to main content

JsonlRfMemory

Struct JsonlRfMemory 

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

A file-backed RfMemoryStore. See the module docs for the on-disk format.

Implementations§

Source§

impl JsonlRfMemory

Source

pub fn create(path: impl AsRef<Path>) -> Result<Self, RvcsiError>

Create a new, empty store at path, truncating any existing file.

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, RvcsiError>

Open an existing store at path, replaying every line into the in-memory index, then positioning for appends. The file must exist (use JsonlRfMemory::create otherwise).

Source

pub fn path(&self) -> &Path

Path the store is backed by.

Source

pub fn flush(&mut self) -> Result<(), RvcsiError>

Flush buffered writes to disk.

Trait Implementations§

Source§

impl Debug for JsonlRfMemory

Source§

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

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

impl RfMemoryStore for JsonlRfMemory

Source§

fn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>

Store the embedding of w, returning its newly-minted id.
Source§

fn store_event(&mut self, e: &CsiEvent) -> Result<EmbeddingId, RvcsiError>

Store the embedding of e, returning its newly-minted id.
Source§

fn query_similar( &self, query: &[f32], k: usize, ) -> Result<Vec<SimilarHit>, RvcsiError>

Return up to k stored records most similar to query, by descending cosine similarity. Records whose embedding length differs from query (e.g. events vs. window queries) score 0.0 and so sort last.
Source§

fn set_baseline( &mut self, room: &str, version: &str, embedding: Vec<f32>, ) -> Result<(), RvcsiError>

Set (or replace) the baseline embedding for room at version.
Source§

fn compute_drift( &self, room: &str, current: &[f32], threshold: f32, ) -> Result<Option<DriftReport>, RvcsiError>

Compare current against room’s baseline. Returns None if there is no baseline for room, otherwise a DriftReport with distance = 1 - cosine_similarity(baseline, current) and exceeded = distance > threshold.
Source§

fn len(&self) -> usize

Number of stored records (windows + events; baselines are not counted).
Source§

fn is_empty(&self) -> bool

Whether RfMemoryStore::len is zero.

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.