pub struct Store { /* private fields */ }Expand description
Handle to the search database.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open_for_build(db_path: &Path) -> Result<Self, RepographError>
pub fn open_for_build(db_path: &Path) -> Result<Self, RepographError>
Open the index for building, creating the file and schema if absent. A schema-version mismatch wipes and recreates all tables.
§Errors
Returns RepographError::Index on any SQLite failure.
Sourcepub fn open_existing(db_path: &Path) -> Result<Self, RepographError>
pub fn open_existing(db_path: &Path) -> Result<Self, RepographError>
Open an existing index read-only. Both callers (search,
index_health) only query, so a read-only handle avoids write-lock
contention with a concurrent repograph index and works on read-only
mounts. Returns RepographError::IndexMissing (exit 3) when the file
does not exist, and RepographError::Index (exit 1) when it exists but
cannot be opened or is the wrong schema.
§Errors
See above.
Sourcepub fn ensure_model(&self, model_id: &str) -> Result<(), RepographError>
pub fn ensure_model(&self, model_id: &str) -> Result<(), RepographError>
If model_id differs from the model recorded in the index, drop every
vector so the segment never mixes embedding spaces, then record the new
model. Call once before reconciling with an embedder.
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn has_vectors(&self) -> Result<bool, RepographError>
pub fn has_vectors(&self) -> Result<bool, RepographError>
Whether any embeddings are stored — drives whether semantic retrieval can run at query time.
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn indexed_commits(
&self,
) -> Result<HashMap<String, Option<String>>, RepographError>
pub fn indexed_commits( &self, ) -> Result<HashMap<String, Option<String>>, RepographError>
The per-repo indexed commit recorded at the last build.
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn reconcile_repo(
&mut self,
repo: &str,
files: &[TrackedFile],
head_commit: Option<&str>,
embedder: Option<&mut dyn Embedder>,
) -> Result<RepoStats, RepographError>
pub fn reconcile_repo( &mut self, repo: &str, files: &[TrackedFile], head_commit: Option<&str>, embedder: Option<&mut dyn Embedder>, ) -> Result<RepoStats, RepographError>
Reconcile one repo’s tracked files against the index in a single
transaction: re-chunk new/changed files, purge files no longer tracked,
and record the indexed commit. When embedder is supplied, changed
chunks are embedded and their vectors written; an embed failure for a
file degrades that file to lexical-only (logged by the caller).
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn search_lexical(
&self,
query: &str,
repos: &[String],
pool: usize,
) -> Result<Vec<i64>, RepographError>
pub fn search_lexical( &self, query: &str, repos: &[String], pool: usize, ) -> Result<Vec<i64>, RepographError>
Lexical (BM25) candidate chunk ids, best-first. repos (when non-empty)
restricts results to those repos. Returns an empty vec when the query
yields no usable search tokens.
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn search_vectors(
&self,
query_embedding: &[f32],
repos: &[String],
pool: usize,
) -> Result<Vec<i64>, RepographError>
pub fn search_vectors( &self, query_embedding: &[f32], repos: &[String], pool: usize, ) -> Result<Vec<i64>, RepographError>
Vector (cosine) candidate chunk ids, best-first, computed by brute force
over the stored embeddings (optionally restricted to repos).
§Errors
Returns RepographError::Index on SQLite failure.
Sourcepub fn fetch_chunks(
&self,
ids: &[i64],
) -> Result<HashMap<i64, ChunkRow>, RepographError>
pub fn fetch_chunks( &self, ids: &[i64], ) -> Result<HashMap<i64, ChunkRow>, RepographError>
Fetch chunk rows for the given ids, keyed by id.
§Errors
Returns RepographError::Index on SQLite failure.