pub struct IndexStore { /* private fields */ }Implementations§
Source§impl IndexStore
impl IndexStore
Sourcepub fn open(path: &Path) -> Result<Self>
pub fn open(path: &Path) -> Result<Self>
Open a database, creating it if it doesn’t exist.
This method always succeeds if the file can be created/opened.
Use try_open() for version-aware opening with migration support.
Sourcepub fn try_open(path: &Path) -> Result<DbOpenResult>
pub fn try_open(path: &Path) -> Result<DbOpenResult>
Try to open a database with version checking.
Returns DbOpenResult::Ready if the database is compatible.
Returns DbOpenResult::NeedsRegeneration if the database needs to be rebuilt.
pub fn remove_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
pub fn list_paths(&self) -> Result<HashSet<String>>
pub fn save_file_index( &self, file_record: &FileRecord, symbols: &[SymbolRecord], edges: &[EdgeRecord], references: &[ReferenceRecord], ) -> Result<()>
Sourcepub fn save_file_index_without_refs(
&self,
file_record: &FileRecord,
symbols: &[SymbolRecord],
edges: &[EdgeRecord],
) -> Result<()>
pub fn save_file_index_without_refs( &self, file_record: &FileRecord, symbols: &[SymbolRecord], edges: &[EdgeRecord], ) -> Result<()>
Save file index without references (used in two-phase indexing first pass)
Sourcepub fn save_references(
&self,
file_path: &str,
references: &[ReferenceRecord],
) -> Result<()>
pub fn save_references( &self, file_path: &str, references: &[ReferenceRecord], ) -> Result<()>
Save resolved references for a file (used in two-phase indexing second pass)
pub fn db_path(&self) -> &Path
Sourcepub fn analyze(&self) -> Result<()>
pub fn analyze(&self) -> Result<()>
Update query optimizer statistics for better index usage. Should be called after bulk indexing operations.
Sourcepub fn get_file_stats(&self, file: &str) -> Result<Option<FileStats>>
pub fn get_file_stats(&self, file: &str) -> Result<Option<FileStats>>
Get pre-computed statistics for a file (O(1) lookup).
Sourcepub fn get_total_stats(&self) -> Result<FileStats>
pub fn get_total_stats(&self) -> Result<FileStats>
Get total symbol counts across all indexed files (O(1) aggregate).
Sourcepub fn save_file_dependencies(
&self,
from_file: &str,
dependencies: &[FileDependency],
) -> Result<()>
pub fn save_file_dependencies( &self, from_file: &str, dependencies: &[FileDependency], ) -> Result<()>
Save file dependencies for a source file, replacing any existing dependencies.
Sourcepub fn get_file_dependencies(&self, file: &str) -> Result<Vec<FileDependency>>
pub fn get_file_dependencies(&self, file: &str) -> Result<Vec<FileDependency>>
Get files that a given file depends on (imports/uses).
Sourcepub fn get_dependents(&self, file: &str) -> Result<Vec<String>>
pub fn get_dependents(&self, file: &str) -> Result<Vec<String>>
Get files that depend on a given file (reverse dependencies for invalidation).
Sourcepub fn get_all_dependencies(&self) -> Result<Vec<FileDependency>>
pub fn get_all_dependencies(&self) -> Result<Vec<FileDependency>>
Get all file dependencies in the workspace.
Sourcepub fn topological_sort(&self, files: &[String]) -> Result<Vec<String>>
pub fn topological_sort(&self, files: &[String]) -> Result<Vec<String>>
Topologically sort files for rebuild ordering. Returns files in an order where dependencies come before dependents. Uses Kahn’s algorithm with O(V + E) complexity. Files with cycles are appended at the end in arbitrary order.
Sourcepub fn get_invalidation_set(&self, changed_file: &str) -> Result<Vec<String>>
pub fn get_invalidation_set(&self, changed_file: &str) -> Result<Vec<String>>
Get all files that need to be invalidated when a file changes. Returns the transitive closure of reverse dependencies. Useful for incremental rebuilds when a source file is modified.
Sourcepub fn get_batch_invalidation_set(
&self,
changed_files: &[String],
) -> Result<Vec<String>>
pub fn get_batch_invalidation_set( &self, changed_files: &[String], ) -> Result<Vec<String>>
Get files that need invalidation for multiple changed files. Returns the union of invalidation sets, topologically sorted.
Sourcepub fn load_dependency_cache(&self) -> Result<DependencyCache>
pub fn load_dependency_cache(&self) -> Result<DependencyCache>
Load all dependencies into a DependencyCache for O(1) lookups. Call this once at startup for long-running processes.
pub fn list_symbols( &self, file: Option<&str>, kind: Option<&str>, name: Option<&str>, limit: Option<usize>, ) -> Result<Vec<SymbolRecord>>
Sourcepub fn edges_to(&self, dst: &str) -> Result<Vec<EdgeRecord>>
pub fn edges_to(&self, dst: &str) -> Result<Vec<EdgeRecord>>
Query edges by destination with cached prepared statement.
Sourcepub fn edges_from(&self, src: &str) -> Result<Vec<EdgeRecord>>
pub fn edges_from(&self, src: &str) -> Result<Vec<EdgeRecord>>
Query edges by source with cached prepared statement.
pub fn symbols_by_ids(&self, ids: &[String]) -> Result<Vec<SymbolRecord>>
Sourcepub fn references_for_symbol(
&self,
symbol_id: &str,
) -> Result<Vec<ReferenceRecord>>
pub fn references_for_symbol( &self, symbol_id: &str, ) -> Result<Vec<ReferenceRecord>>
Query references by symbol ID with cached prepared statement.
Sourcepub fn reference_at_position(
&self,
file: &str,
offset: i64,
) -> Result<Option<ReferenceRecord>>
pub fn reference_at_position( &self, file: &str, offset: i64, ) -> Result<Option<ReferenceRecord>>
Find a reference at a specific file and byte offset. Returns the reference record if the offset falls within a recorded reference span.
Sourcepub fn find_duplicate_groups(
&self,
min_count: usize,
kind_filter: Option<&str>,
file_filter: Option<&[String]>,
) -> Result<Vec<DuplicateGroup>>
pub fn find_duplicate_groups( &self, min_count: usize, kind_filter: Option<&str>, file_filter: Option<&[String]>, ) -> Result<Vec<DuplicateGroup>>
Find all groups of duplicate symbols (symbols with the same content_hash). Returns groups sorted by count (most duplicates first). Only includes groups with 2+ symbols and content_hash is not null.
Sourcepub fn symbols_by_content_hash(&self, hash: &str) -> Result<Vec<SymbolRecord>>
pub fn symbols_by_content_hash(&self, hash: &str) -> Result<Vec<SymbolRecord>>
Find all symbols with a specific content hash.
Sourcepub fn content_hashes_in_files(
&self,
files: &[String],
) -> Result<HashSet<String>>
pub fn content_hashes_in_files( &self, files: &[String], ) -> Result<HashSet<String>>
Get content hashes for symbols in specific files. Used for –uncommitted flag to find duplicates involving changed files.
Sourcepub fn search_symbols_fts(&self, query: &str) -> Result<Vec<SymbolRecord>>
pub fn search_symbols_fts(&self, query: &str) -> Result<Vec<SymbolRecord>>
Search symbols using FTS5 full-text search. Supports prefix queries (e.g., “getUser*”) and substring matching via trigram tokenization. Uses cached prepared statement for repeated searches.
Sourcepub fn list_symbols_paginated(
&self,
file: Option<&str>,
kind: Option<&str>,
name: Option<&str>,
cursor: Option<&str>,
page_size: usize,
) -> Result<(Vec<SymbolRecord>, Option<String>)>
pub fn list_symbols_paginated( &self, file: Option<&str>, kind: Option<&str>, name: Option<&str>, cursor: Option<&str>, page_size: usize, ) -> Result<(Vec<SymbolRecord>, Option<String>)>
Query symbols with cursor-based pagination for streaming large result sets. Returns (results, next_cursor) where next_cursor can be used to fetch the next page.