pub struct JsonlRfMemory { /* private fields */ }Expand description
A file-backed RfMemoryStore. See the module docs for the on-disk format.
Implementations§
Source§impl JsonlRfMemory
impl JsonlRfMemory
Sourcepub fn create(path: impl AsRef<Path>) -> Result<Self, RvcsiError>
pub fn create(path: impl AsRef<Path>) -> Result<Self, RvcsiError>
Create a new, empty store at path, truncating any existing file.
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, RvcsiError>
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).
Sourcepub fn flush(&mut self) -> Result<(), RvcsiError>
pub fn flush(&mut self) -> Result<(), RvcsiError>
Flush buffered writes to disk.
Trait Implementations§
Source§impl Debug for JsonlRfMemory
impl Debug for JsonlRfMemory
Source§impl RfMemoryStore for JsonlRfMemory
impl RfMemoryStore for JsonlRfMemory
Source§fn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>
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>
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>
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>
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>
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
fn len(&self) -> usize
Number of stored records (windows + events; baselines are not counted).
Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Whether
RfMemoryStore::len is zero.Auto Trait Implementations§
impl Freeze for JsonlRfMemory
impl RefUnwindSafe for JsonlRfMemory
impl Send for JsonlRfMemory
impl Sync for JsonlRfMemory
impl Unpin for JsonlRfMemory
impl UnsafeUnpin for JsonlRfMemory
impl UnwindSafe for JsonlRfMemory
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
Mutably borrows from an owned value. Read more