Skip to main content

MemoryDatabase

Struct MemoryDatabase 

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

Database connection manager

Implementations§

Source§

impl MemoryDatabase

Source

pub async fn new(db_path: &Path) -> MemoryResult<Self>

Initialize or open the memory database

Source

pub async fn validate_vector_tables(&self) -> MemoryResult<()>

Validate that sqlite-vec tables are readable. This catches legacy/corrupted vector blobs early so startup can recover.

Source

pub async fn ensure_vector_tables_healthy(&self) -> MemoryResult<bool>

Ensure vector tables are readable and recreate them if corruption is detected. Returns true when a repair was performed.

Source

pub async fn store_chunk( &self, chunk: &MemoryChunk, embedding: &[f32], ) -> MemoryResult<()>

Store a chunk with its embedding

Source

pub async fn search_similar( &self, query_embedding: &[f32], tier: MemoryTier, project_id: Option<&str>, session_id: Option<&str>, limit: i64, ) -> MemoryResult<Vec<(MemoryChunk, f64)>>

Search for similar chunks

Source

pub async fn get_session_chunks( &self, session_id: &str, ) -> MemoryResult<Vec<MemoryChunk>>

Get chunks by session ID

Source

pub async fn get_project_chunks( &self, project_id: &str, ) -> MemoryResult<Vec<MemoryChunk>>

Get chunks by project ID

Source

pub async fn get_global_chunks( &self, limit: i64, ) -> MemoryResult<Vec<MemoryChunk>>

Get global chunks

Source

pub async fn clear_session_memory(&self, session_id: &str) -> MemoryResult<u64>

Clear session memory

Source

pub async fn clear_project_memory(&self, project_id: &str) -> MemoryResult<u64>

Clear project memory

Source

pub async fn cleanup_old_sessions( &self, retention_days: i64, ) -> MemoryResult<u64>

Clear old session memory based on retention policy

Source

pub async fn get_or_create_config( &self, project_id: &str, ) -> MemoryResult<MemoryConfig>

Get or create memory config for a project

Source

pub async fn update_config( &self, project_id: &str, config: &MemoryConfig, ) -> MemoryResult<()>

Update memory config for a project

Source

pub async fn get_stats(&self) -> MemoryResult<MemoryStats>

Get memory statistics

Source

pub async fn log_cleanup( &self, cleanup_type: &str, tier: MemoryTier, project_id: Option<&str>, session_id: Option<&str>, chunks_deleted: i64, bytes_reclaimed: i64, ) -> MemoryResult<()>

Log cleanup operation

Source

pub async fn vacuum(&self) -> MemoryResult<()>

Vacuum the database to reclaim space

Source

pub async fn project_file_index_count( &self, project_id: &str, ) -> MemoryResult<i64>

Source

pub async fn project_has_file_chunks( &self, project_id: &str, ) -> MemoryResult<bool>

Source

pub async fn get_file_index_entry( &self, project_id: &str, path: &str, ) -> MemoryResult<Option<(i64, i64, String)>>

Source

pub async fn upsert_file_index_entry( &self, project_id: &str, path: &str, mtime: i64, size: i64, hash: &str, ) -> MemoryResult<()>

Source

pub async fn delete_file_index_entry( &self, project_id: &str, path: &str, ) -> MemoryResult<()>

Source

pub async fn list_file_index_paths( &self, project_id: &str, ) -> MemoryResult<Vec<String>>

Source

pub async fn delete_project_file_chunks_by_path( &self, project_id: &str, source_path: &str, ) -> MemoryResult<(i64, i64)>

Source

pub async fn upsert_project_index_status( &self, project_id: &str, total_files: i64, processed_files: i64, indexed_files: i64, skipped_files: i64, errors: i64, ) -> MemoryResult<()>

Source

pub async fn get_project_stats( &self, project_id: &str, ) -> MemoryResult<ProjectMemoryStats>

Source

pub async fn clear_project_file_index( &self, project_id: &str, vacuum: bool, ) -> MemoryResult<ClearFileIndexResult>

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more