Skip to main content

ChunkStore

Struct ChunkStore 

Source
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

Source

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.

Source

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
Source

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 - Arc implementation
Source

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.

Source

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).

Source

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

Ensure the code_chunks table exists.

Source

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).

Source

pub fn store_chunks(&self, chunks: &[CodeChunk]) -> Result<Vec<i64>>

Store multiple code chunks in a transaction.

Source

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.

Source

pub fn get_chunks_for_file(&self, file_path: &str) -> Result<Vec<CodeChunk>>

Get all code chunks for a specific file.

Source

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.

Source

pub fn delete_chunks_for_file(&self, file_path: &str) -> Result<usize>

Delete all code chunks for a specific file.

Source

pub fn count_chunks(&self) -> Result<usize>

Count total code chunks stored.

Source

pub fn count_chunks_for_file(&self, file_path: &str) -> Result<usize>

Count code chunks for a specific file.

Source

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.

Source

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.

Source

pub fn get_chunks_by_kind(&self, symbol_kind: &str) -> Result<Vec<CodeChunk>>

Get chunks by symbol kind (e.g., “fn”, “struct”).

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, 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V