Skip to main content

sochdb_query/executor/
mod.rs

1// SPDX-License-Identifier: AGPL-3.0-or-later
2// SochDB - LLM-Optimized Embedded Database
3// Copyright (C) 2026 Sushanth Reddy Vanagala (https://github.com/sushanthpy)
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Affero General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9
10//! # Unified Volcano Query Executor (v1.0)
11//!
12//! Single pipeline for all SQL execution:
13//!
14//! ```text
15//! SQL Text → Parser → AST → Planner → Volcano Operator Tree → Row-at-a-time → Result
16//! ```
17//!
18//! ## Architecture
19//!
20//! All operators implement the [`PlanNode`] trait (Volcano iterator model):
21//!
22//! ```text
23//! trait PlanNode {
24//!     fn schema(&self) -> &Schema;
25//!     fn next(&mut self) -> Result<Option<Row>>;
26//! }
27//! ```
28//!
29//! Operators form a tree: each `next()` call pulls one row from its children,
30//! processes it, and returns the result. This enables streaming execution
31//! with minimal memory footprint.
32//!
33//! ## Operators
34//!
35//! | Operator       | Description                                |
36//! |----------------|--------------------------------------------|
37//! | SeqScan        | Full table scan via StorageBackend         |
38//! | IndexSeek      | Index-based lookup via StorageBackend      |
39//! | Filter         | Predicate evaluation (WHERE)               |
40//! | Project        | Column selection + expression eval         |
41//! | Sort           | In-memory sort (materializing)             |
42//! | Limit          | LIMIT + OFFSET                             |
43//! | HashJoin       | Hash-based equi-join                       |
44//! | NestedLoopJoin | Nested loop join (theta joins)             |
45//! | MergeJoin      | Merge join on sorted inputs                |
46//! | HashAggregate  | GROUP BY + aggregate functions              |
47//! | Explain        | EXPLAIN plan output                        |
48//! | Values         | Inline VALUES (...) rows                   |
49//! | Empty          | Returns no rows                            |
50
51pub mod types;
52pub mod node;
53pub mod eval;
54pub mod scan;
55pub mod filter;
56pub mod project;
57pub mod sort;
58pub mod limit;
59pub mod join;
60pub mod aggregate;
61pub mod explain;
62pub mod planner;
63pub mod pipeline;
64
65#[cfg(test)]
66mod tests;
67
68// Re-exports
69pub use types::{Row, Schema, ColumnMeta};
70pub use node::PlanNode;
71pub use eval::{eval_expr, eval_predicate};
72pub use scan::{SeqScanNode, IndexSeekNode};
73pub use filter::FilterNode;
74pub use project::ProjectNode;
75pub use sort::SortNode;
76pub use limit::LimitNode;
77pub use join::{HashJoinNode, NestedLoopJoinNode, MergeJoinNode};
78pub use aggregate::HashAggregateNode;
79pub use explain::ExplainNode;
80pub use planner::QueryPlanner;
81pub use pipeline::{execute_sql, execute_statement, ExecutorConfig};