pub struct InMemoryStore { /* private fields */ }Expand description
In-memory record store.
Stores records in a HashMap for O(1) access.
§Example
ⓘ
use rag_plusplus_core::store::{InMemoryStore, RecordStore};
use rag_plusplus_core::types::MemoryRecord;
let mut store = InMemoryStore::new();
store.insert(record)?;
if let Some(record) = store.get(&"my-id".into()) {
println!("Found: {}", record.context);
}Implementations§
Source§impl InMemoryStore
impl InMemoryStore
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create store with pre-allocated capacity.
Sourcepub fn iter(&self) -> impl Iterator<Item = &MemoryRecord>
pub fn iter(&self) -> impl Iterator<Item = &MemoryRecord>
Iterate over all records.
Sourcepub fn iter_active(&self) -> impl Iterator<Item = &MemoryRecord>
pub fn iter_active(&self) -> impl Iterator<Item = &MemoryRecord>
Iterate over active records only.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Estimated memory usage in bytes.
Trait Implementations§
Source§impl Debug for InMemoryStore
impl Debug for InMemoryStore
Source§impl Default for InMemoryStore
impl Default for InMemoryStore
Source§fn default() -> InMemoryStore
fn default() -> InMemoryStore
Returns the “default value” for a type. Read more
Source§impl RecordStore for InMemoryStore
impl RecordStore for InMemoryStore
Source§fn update_stats(&mut self, id: &RecordId, outcome: f64) -> Result<()>
fn update_stats(&mut self, id: &RecordId, outcome: f64) -> Result<()>
Update the outcome statistics for a record. Read more
Source§fn remove(&mut self, id: &RecordId) -> Result<bool>
fn remove(&mut self, id: &RecordId) -> Result<bool>
Remove a record (marks as deleted, may not physically remove). Read more
Source§fn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Get memory usage estimate in bytes.
Source§fn insert_batch(&mut self, records: Vec<MemoryRecord>) -> Result<Vec<RecordId>>
fn insert_batch(&mut self, records: Vec<MemoryRecord>) -> Result<Vec<RecordId>>
Insert multiple records in batch. Read more
Auto Trait Implementations§
impl Freeze for InMemoryStore
impl RefUnwindSafe for InMemoryStore
impl Send for InMemoryStore
impl Sync for InMemoryStore
impl Unpin for InMemoryStore
impl UnwindSafe for InMemoryStore
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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>
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 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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.