-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
1,229 additions
and
425 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
use crate::dml::MutationPlan; | ||
use crate::plan::ProjectListPlan; | ||
use spacetimedb_expr::StatementSource; | ||
use std::collections::HashMap; | ||
|
||
pub mod compile; | ||
pub mod dml; | ||
pub mod plan; | ||
pub mod printer; | ||
pub mod rules; | ||
|
||
#[derive(Debug)] | ||
pub enum PlanCtx { | ||
ProjectList(ProjectListPlan), | ||
DML(MutationPlan), | ||
} | ||
|
||
impl PlanCtx { | ||
pub(crate) fn optimize(self) -> PlanCtx { | ||
match self { | ||
Self::ProjectList(plan) => Self::ProjectList(plan.optimize()), | ||
Self::DML(plan) => Self::DML(plan.optimize()), | ||
} | ||
} | ||
} | ||
|
||
/// A physical context for the result of a query compilation. | ||
#[derive(Debug)] | ||
pub struct PhysicalCtx<'a> { | ||
pub plan: PlanCtx, | ||
pub sql: &'a str, | ||
// A map from table names to their labels | ||
pub vars: HashMap<String, usize>, | ||
pub source: StatementSource, | ||
pub planning_time: Option<std::time::Duration>, | ||
} | ||
|
||
impl PhysicalCtx<'_> { | ||
pub fn optimize(self) -> Self { | ||
Self { | ||
plan: self.plan.optimize(), | ||
..self | ||
} | ||
} | ||
} |
Oops, something went wrong.