Skip to main content

Storage

Struct Storage 

Source
pub struct Storage {
    pub db_path: PathBuf,
    pub content_dim: usize,
    pub trigger_dim: usize,
    /* private fields */
}

Fields§

§db_path: PathBuf§content_dim: usize§trigger_dim: usize

Implementations§

Source§

impl Storage

Source

pub fn open( db_path: impl AsRef<Path>, content_dim: usize, trigger_dim: usize, ) -> Result<Self>

Source

pub fn open_readonly(db_path: impl AsRef<Path>) -> Result<Self>

Source

pub fn begin_immediate(&self) -> Result<()>

Source

pub fn commit(&self) -> Result<()>

Source

pub fn rollback(&self) -> Result<()>

Source

pub fn get_meta(&self, key: &str) -> Result<Option<String>>

Source

pub fn set_meta(&self, key: &str, value: &str) -> Result<()>

Source

pub fn get_meta_or(&self, key: &str, default: &str) -> String

Source

pub fn insert_chunk(&self, c: &ChunkRow) -> Result<()>

Source

pub fn insert_vec_content(&self, chunk_id: &str, emb: &[u8]) -> Result<()>

Source

pub fn insert_vec_trigger(&self, chunk_id: &str, emb: &[u8]) -> Result<()>

Source

pub fn get_chunk(&self, id: &str) -> Result<Option<Value>>

Source

pub fn update_chunk_state( &self, id: &str, state: &str, reason: Option<&str>, now: &str, ) -> Result<()>

Source

pub fn update_chunk_confidence( &self, id: &str, conf: f64, reason: Option<&str>, now: &str, ) -> Result<()>

Source

pub fn update_chunk_last_used(&self, id: &str, now: &str) -> Result<()>

Source

pub fn get_chunk_by_hash(&self, hash: &str) -> Result<Option<Value>>

Source

pub fn search_vec_content( &self, query: &[f32], limit: usize, ) -> Result<Vec<(String, f32)>>

Source

pub fn search_vec_trigger( &self, query: &[f32], limit: usize, ) -> Result<Vec<(String, f32)>>

Source

pub fn is_hash_invalidated(&self, hash: &str) -> Result<bool>

Source

pub fn insert_invalidated_hash( &self, hash: &str, reason: Option<&str>, ts: &str, ) -> Result<()>

Source

pub fn insert_usage_trace( &self, trace_id: &str, chunk_id: Option<&str>, event: &str, strength: f64, similarity: Option<f64>, refine_mode: Option<&str>, tokens: Option<i64>, rank: Option<i64>, source: &str, ts: &str, ) -> Result<()>

Source

pub fn get_outcome_for_trace(&self, trace_id: &str) -> Result<Option<String>>

Source

pub fn purge_usage_trace(&self, before_ts: &str) -> Result<usize>

Source

pub fn upsert_episodic_log(&self, log: &EpisodicLogRow) -> Result<()>

Source

pub fn get_episodic_log(&self, trace_id: &str) -> Result<Option<Value>>

Source

pub fn update_episodic_log_state( &self, trace_id: &str, state: &str, note: Option<&str>, outcome: Option<&str>, ) -> Result<()>

Source

pub fn patch_episodic_log_content( &self, trace_id: &str, query: Option<&str>, output: Option<&str>, output_summary: Option<&str>, nomination: Option<&str>, priority: i64, ) -> Result<()>

Patch content fields on an existing episodic_log row (補写: output_summary, nomination, etc.)

Source

pub fn update_episodic_log_state_by_id( &self, id: &str, state: &str, note: Option<&str>, outcome: Option<&str>, ) -> Result<()>

Update by primary-key id (used after distill where we have the row id, not trace_id).

Source

pub fn update_episodic_log_tokens( &self, id: &str, prompt_tokens: i64, completion_tokens: i64, ) -> Result<()>

Source

pub fn claim_distill_batch( &self, run_id: &str, limit: usize, locked_at: &str, ) -> Result<Vec<Value>>

Claim a batch of ‘new’ logs for distillation: mark them ‘screening’ atomically. Returns the claimed rows (with distill_run_id set to run_id).

Source

pub fn query_episodic_logs_open(&self, limit: usize) -> Result<Vec<Value>>

Source

pub fn query_chunks(&self, sql: &str) -> Result<Vec<Value>>

Source

pub fn query_chunks_params<P: Params>( &self, sql: &str, p: P, ) -> Result<Vec<Value>>

Source

pub fn get_deps( &self, chunk_id: &str, ) -> Result<Vec<(String, String, Option<String>)>>

Source

pub fn get_reverse_deps(&self, chunk_id: &str) -> Result<Vec<String>>

Source

pub fn insert_dep( &self, src: &str, dst: &str, kind: &str, dst_lib: Option<&str>, ) -> Result<()>

Source

pub fn upsert_chunk_success_trace( &self, chunk_id: &str, trace_id: &str, ts: &str, ) -> Result<()>

Source

pub fn attach_shared(&self, path: &str, alias: &str) -> Result<()>

Source

pub fn lib_id(&self) -> Result<String>

Source

pub fn execute(&self, sql: &str) -> Result<()>

Source

pub fn conn_execute<P: Params>(&self, sql: &str, p: P) -> Result<()>

Execute a parameterised statement (not batch); returns rows-affected count.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.