pub struct Analytics { /* private fields */ }Expand description
DuckDB analytics engine for code intelligence.
Implementations§
Source§impl Analytics
impl Analytics
Sourcepub fn call_graph(
&self,
start_name: &str,
max_depth: i32,
) -> Result<Vec<CallGraphNode>>
pub fn call_graph( &self, start_name: &str, max_depth: i32, ) -> Result<Vec<CallGraphNode>>
Get the full call graph starting from a symbol (forward traversal).
The start_name can be:
- A simple name like “new” (matches first symbol with that name)
- A qualified name like “LocalProvider::new”
- A full ID like “src/embeddings/local.rs::LocalProvider::new@20”
Sourcepub fn impact_analysis(
&self,
target_name: &str,
max_depth: i32,
) -> Result<Vec<ImpactNode>>
pub fn impact_analysis( &self, target_name: &str, max_depth: i32, ) -> Result<Vec<ImpactNode>>
Impact analysis: find all symbols that would be affected by changing the target.
The target_name can be:
- A simple name like “new” (matches first symbol with that name)
- A qualified name like “LocalProvider::new”
- A full ID like “src/embeddings/local.rs::LocalProvider::new@20”
Sourcepub fn file_statistics(&self) -> Result<Vec<FileStats>>
pub fn file_statistics(&self) -> Result<Vec<FileStats>>
Get file statistics for all indexed files.
Sourcepub fn has_path(
&self,
from_name: &str,
to_name: &str,
max_depth: i32,
) -> Result<bool>
pub fn has_path( &self, from_name: &str, to_name: &str, max_depth: i32, ) -> Result<bool>
Find if a path exists between two symbols (simplified version).
Both from_name and to_name can be symbol IDs, qualified names, or simple names.
Sourcepub fn most_connected(
&self,
limit: i32,
) -> Result<Vec<(String, String, i64, i64)>>
pub fn most_connected( &self, limit: i32, ) -> Result<Vec<(String, String, i64, i64)>>
Get the most connected symbols (highest in/out degree).
This correctly counts incoming edges per symbol ID, not by name, avoiding over-counting for common names like “new”.
Sourcepub fn find_recursive_functions(&self) -> Result<Vec<(String, String)>>
pub fn find_recursive_functions(&self) -> Result<Vec<(String, String)>>
Check if there are any self-recursive functions.
Uses target_id when available for accurate recursion detection.
Sourcepub fn file_dependencies(&self) -> Result<Vec<(String, String, i64)>>
pub fn file_dependencies(&self) -> Result<Vec<(String, String, i64)>>
Get dependency graph between files (module-level).
Uses target_id when available for accurate file resolution.
Sourcepub fn complexity_analysis(
&self,
threshold: i64,
) -> Result<Vec<ComplexityResult>>
pub fn complexity_analysis( &self, threshold: i64, ) -> Result<Vec<ComplexityResult>>
Analyze code complexity based on fan-out (outgoing calls) and fan-in (incoming calls).
This correctly counts incoming edges per symbol ID, not by name, avoiding over-counting for common names like “new”.
Sourcepub fn full_call_graph(
&self,
_max_depth: i32,
) -> Result<Vec<(String, String, String, String)>>
pub fn full_call_graph( &self, _max_depth: i32, ) -> Result<Vec<(String, String, String, String)>>
Get the full call graph (all edges with resolved symbols).
Uses target_id when available for accurate symbol resolution.
Sourcepub fn open_sql_sandbox(root: &Path, snapshots: Option<&Path>) -> Result<Self>
pub fn open_sql_sandbox(root: &Path, snapshots: Option<&Path>) -> Result<Self>
Open DuckDB for the ctx sql command: attach the SQLite index read-only,
build the public v1 view layer, optionally materialize snapshot
partitions as snap.* tables, then lock the engine down so untrusted
user SQL cannot touch the filesystem, load extensions, or re-enable any
of that. Safety is enforced entirely by engine configuration — never by
inspecting the SQL text.
snapshots, when set, is a directory of sha=<sha>/ Parquet
partitions written by ctx snapshot; each partition’s four files are
loaded into in-memory tables snap.files, snap.symbols,
snap.dup_pairs, and snap.meta.
Sourcepub fn open_export(root: &Path) -> Result<Self>
pub fn open_export(root: &Path) -> Result<Self>
Open DuckDB for snapshot export (ctx snapshot): attach the SQLite
index read-only and build the same public v1 view layer as
Analytics::open_sql_sandbox, but with no engine hardening
(enable_external_access stays on so COPY ... TO ... (FORMAT PARQUET) can write partition files).
This is a trusted internal path: it only ever executes SQL composed by
ctx itself and is never fed user SQL. Anything user-facing must go
through the hardened Analytics::open_sql_sandbox instead.
Sourcepub fn interrupt_handle(&self) -> Arc<InterruptHandle>
pub fn interrupt_handle(&self) -> Arc<InterruptHandle>
A handle that can interrupt an in-flight query from another thread
(used to enforce --timeout). InterruptHandle is Send + Sync.
Sourcepub fn exec_non_final_statement(&self, sql: &str) -> Result<bool>
pub fn exec_non_final_statement(&self, sql: &str) -> Result<bool>
Execute a non-final statement in a multi-statement submission.
Returns Ok(true) if the statement produces a result set — the caller
rejects that (only the final statement may return rows, per the one
result-set rule). Statements that produce no result set (e.g.
CREATE TEMP TABLE …, SET …) are executed for their side effects and
return Ok(false).
(DuckDB only knows a statement’s column count after execution, so the statement is always run — harmless here, since the index is read-only and the in-memory DuckDB is throwaway.)
Sourcepub fn run_final_statement(
&self,
sql: &str,
max_rows: usize,
) -> Result<SqlResult>
pub fn run_final_statement( &self, sql: &str, max_rows: usize, ) -> Result<SqlResult>
Run the final (result-producing) statement, streaming rows and stopping
once max_rows is reached (0 = unlimited). One extra row is fetched to
detect truncation, so the full result is never materialized in Rust.
Auto Trait Implementations§
impl !Freeze for Analytics
impl !RefUnwindSafe for Analytics
impl !Sync for Analytics
impl Send for Analytics
impl Unpin for Analytics
impl UnsafeUnpin for Analytics
impl UnwindSafe for Analytics
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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