pub struct ChunkStore { /* private fields */ }Expand description
Code chunk storage operations.
Can use either its own connections (legacy), a shared connection provided by CodeGraph for transactional operations, or the SideTables abstraction for backend-agnostic storage (V3).
Implementations§
Source§impl ChunkStore
impl ChunkStore
Sourcepub fn new(db_path: &Path) -> Self
pub fn new(db_path: &Path) -> Self
Create a new ChunkStore with the given database path.
This is the legacy constructor that opens its own connections.
Sourcepub fn with_connection(conn: Connection) -> Self
pub fn with_connection(conn: Connection) -> Self
Create a ChunkStore with a shared connection.
This constructor enables transactional operations by using a connection shared with CodeGraph. All operations will use this shared connection.
§Arguments
conn- Shared SQLite connection wrapped in Arc<Mutex<>> for thread-safe interior mutability
Sourcepub fn with_side_tables(side_tables: Arc<dyn SideTables>) -> Self
pub fn with_side_tables(side_tables: Arc<dyn SideTables>) -> Self
Create a ChunkStore using the SideTables abstraction.
This constructor is used for V3 backend where we want to avoid SQLite entirely for side tables.
§Arguments
side_tables- Arcimplementation
Sourcepub fn in_memory() -> Self
pub fn in_memory() -> Self
Create a stub ChunkStore using a temporary file (for testing).
Uses a temporary file so that new connections can access the same data.
Sourcepub fn connect(&self) -> Result<Connection, Error>
pub fn connect(&self) -> Result<Connection, Error>
Get a connection to the database.
For owned connections, opens a new connection. For shared connections, also opens a new connection (to the same database).
Note: This method always opens a NEW connection, even when using shared mode. This is needed for operations that require raw access to the connection, such as delete_edges_touching_entities which operates on sqlitegraph tables.
§Panics
Panics if called when using SideTables backend (not applicable).
Sourcepub fn ensure_schema(&self) -> Result<()>
pub fn ensure_schema(&self) -> Result<()>
Ensure the code_chunks table exists.
Sourcepub fn store_chunk(&self, chunk: &CodeChunk) -> Result<i64>
pub fn store_chunk(&self, chunk: &CodeChunk) -> Result<i64>
Store a code chunk in the database.
Uses INSERT OR REPLACE to handle duplicates based on (file_path, byte_start, byte_end).
Sourcepub fn store_chunks(&self, chunks: &[CodeChunk]) -> Result<Vec<i64>>
pub fn store_chunks(&self, chunks: &[CodeChunk]) -> Result<Vec<i64>>
Store multiple code chunks in a transaction.
Sourcepub fn get_chunk_by_span(
&self,
file_path: &str,
byte_start: usize,
byte_end: usize,
) -> Result<Option<CodeChunk>>
pub fn get_chunk_by_span( &self, file_path: &str, byte_start: usize, byte_end: usize, ) -> Result<Option<CodeChunk>>
Get a code chunk by file path and byte span.
Sourcepub fn get_chunks_for_file(&self, file_path: &str) -> Result<Vec<CodeChunk>>
pub fn get_chunks_for_file(&self, file_path: &str) -> Result<Vec<CodeChunk>>
Get all code chunks for a specific file.
Sourcepub fn get_chunks_for_symbol(
&self,
file_path: &str,
symbol_name: &str,
) -> Result<Vec<CodeChunk>>
pub fn get_chunks_for_symbol( &self, file_path: &str, symbol_name: &str, ) -> Result<Vec<CodeChunk>>
Get code chunks for a specific symbol in a file.
Sourcepub fn delete_chunks_for_file(&self, file_path: &str) -> Result<usize>
pub fn delete_chunks_for_file(&self, file_path: &str) -> Result<usize>
Delete all code chunks for a specific file.
Sourcepub fn count_chunks(&self) -> Result<usize>
pub fn count_chunks(&self) -> Result<usize>
Count total code chunks stored.
Sourcepub fn count_chunks_for_file(&self, file_path: &str) -> Result<usize>
pub fn count_chunks_for_file(&self, file_path: &str) -> Result<usize>
Count code chunks for a specific file.
Sourcepub fn get_all_chunks(&self) -> Result<Vec<CodeChunk>>
pub fn get_all_chunks(&self) -> Result<Vec<CodeChunk>>
Get all code chunks from storage.
For SQLite, queries the code_chunks table. For V3, uses SideTables trait method.
Sourcepub fn has_kv_backend(&self) -> bool
pub fn has_kv_backend(&self) -> bool
Check if this ChunkStore is using KV backend
This method always returns false since the KV backend was removed.
Auto Trait Implementations§
impl Freeze for ChunkStore
impl !RefUnwindSafe for ChunkStore
impl Send for ChunkStore
impl Sync for ChunkStore
impl Unpin for ChunkStore
impl UnsafeUnpin for ChunkStore
impl !UnwindSafe for ChunkStore
Blanket Implementations§
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
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>
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>
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 more