mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-20 07:25:14 +01:00
add DBSP circuit compiler
The next step is to adapt the view code to use circuits instead of listing the operators manually.
This commit is contained in:
2922
core/incremental/compiler.rs
Normal file
2922
core/incremental/compiler.rs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
pub mod compiler;
|
||||
pub mod dbsp;
|
||||
pub mod expr_compiler;
|
||||
pub mod hashable_row;
|
||||
|
||||
@@ -359,7 +359,7 @@ pub enum JoinType {
|
||||
Right,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AggregateFunction {
|
||||
Count,
|
||||
Sum(String),
|
||||
@@ -774,6 +774,46 @@ impl ProjectOperator {
|
||||
})
|
||||
}
|
||||
|
||||
/// Create a ProjectOperator from pre-compiled expressions
|
||||
pub fn from_compiled(
|
||||
compiled_exprs: Vec<CompiledExpression>,
|
||||
aliases: Vec<Option<String>>,
|
||||
input_column_names: Vec<String>,
|
||||
output_column_names: Vec<String>,
|
||||
) -> crate::Result<Self> {
|
||||
// Set up internal connection for expression evaluation
|
||||
let io = Arc::new(crate::MemoryIO::new());
|
||||
let db = Database::open_file(
|
||||
io, ":memory:", false, // no MVCC needed for expression evaluation
|
||||
false, // no indexes needed
|
||||
)?;
|
||||
let internal_conn = db.connect()?;
|
||||
// Set to read-only mode and disable auto-commit since we're only evaluating expressions
|
||||
internal_conn.query_only.set(true);
|
||||
internal_conn.auto_commit.set(false);
|
||||
|
||||
// Create ProjectColumn structs from compiled expressions
|
||||
let columns: Vec<ProjectColumn> = compiled_exprs
|
||||
.into_iter()
|
||||
.zip(aliases)
|
||||
.map(|(compiled, alias)| ProjectColumn {
|
||||
// Create a placeholder AST expression since we already have the compiled version
|
||||
expr: turso_parser::ast::Expr::Literal(turso_parser::ast::Literal::Null),
|
||||
alias,
|
||||
compiled,
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(Self {
|
||||
columns,
|
||||
input_column_names,
|
||||
output_column_names,
|
||||
current_state: Delta::new(),
|
||||
tracker: None,
|
||||
internal_conn,
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the columns for this projection
|
||||
pub fn columns(&self) -> &[ProjectColumn] {
|
||||
&self.columns
|
||||
|
||||
@@ -21,7 +21,6 @@ pub(crate) mod group_by;
|
||||
pub(crate) mod index;
|
||||
pub(crate) mod insert;
|
||||
pub(crate) mod integrity_check;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod logical;
|
||||
pub(crate) mod main_loop;
|
||||
pub(crate) mod optimizer;
|
||||
|
||||
Reference in New Issue
Block a user