Skip to content

Commit 0f2e152

Browse files
authored
engine: remove 2 from types and fns (#172)
1 parent 365e220 commit 0f2e152

27 files changed

+115
-122
lines changed

crates/toasty-core/src/stmt/filter.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ impl Statement {
116116
}
117117
}
118118

119+
pub fn filter_expr_unwrap(&self) -> &Expr {
120+
self.filter()
121+
.and_then(|f| f.expr.as_ref())
122+
.expect("expected Statement with expression filter")
123+
}
124+
119125
pub fn filter_expr_mut(&mut self) -> Option<&mut Expr> {
120126
self.filter_mut().and_then(|filter| filter.expr.as_mut())
121127
}

crates/toasty/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use plan::Plan;
44
mod eval;
55
mod exec;
66
mod index;
7-
mod kv2;
7+
mod kv;
88
mod planner;
99
mod simplify;
1010
use simplify::Simplify;

crates/toasty/src/engine/exec.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod delete_by_key;
2-
mod exec_statement2;
2+
mod exec_statement;
33
mod filter;
44
mod find_pk_by_index;
55
mod get_by_key;
@@ -57,15 +57,15 @@ impl Exec<'_> {
5757
async fn exec_step(&mut self, action: &Action) -> Result<()> {
5858
match action {
5959
Action::DeleteByKey(action) => self.action_delete_by_key(action).await,
60-
Action::ExecStatement2(action) => self.action_exec_statement2(action).await,
60+
Action::ExecStatement(action) => self.action_exec_statement(action).await,
6161
Action::Filter(action) => self.action_filter(action).await,
62-
Action::FindPkByIndex2(action) => self.action_find_pk_by_index2(action).await,
63-
Action::GetByKey2(action) => self.action_get_by_key2(action).await,
62+
Action::FindPkByIndex(action) => self.action_find_pk_by_index(action).await,
63+
Action::GetByKey(action) => self.action_get_by_key(action).await,
6464
Action::NestedMerge(action) => self.action_nested_merge(action).await,
65-
Action::QueryPk2(action) => self.action_query_pk2(action).await,
66-
Action::ReadModifyWrite2(action) => self.action_read_modify_write2(action).await,
65+
Action::QueryPk(action) => self.action_query_pk(action).await,
66+
Action::ReadModifyWrite(action) => self.action_read_modify_write(action).await,
6767
Action::Project(action) => self.action_project(action).await,
68-
Action::SetVar2(action) => self.action_set_var2(action),
68+
Action::SetVar(action) => self.action_set_var(action),
6969
Action::UpdateByKey(action) => self.action_update_by_key(action).await,
7070
}
7171
}

crates/toasty/src/engine/exec/exec_statement2.rs renamed to crates/toasty/src/engine/exec/exec_statement.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use toasty_core::{
55
};
66

77
impl Exec<'_> {
8-
pub(super) async fn action_exec_statement2(
8+
pub(super) async fn action_exec_statement(
99
&mut self,
10-
action: &plan::ExecStatement2,
10+
action: &plan::ExecStatement,
1111
) -> Result<()> {
1212
let mut stmt = action.stmt.clone();
1313

crates/toasty/src/engine/exec/find_pk_by_index.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use super::{plan, Exec, Result};
77
use crate::engine::simplify;
88

99
impl Exec<'_> {
10-
pub(super) async fn action_find_pk_by_index2(
10+
pub(super) async fn action_find_pk_by_index(
1111
&mut self,
12-
action: &plan::FindPkByIndex2,
12+
action: &plan::FindPkByIndex,
1313
) -> Result<()> {
1414
let mut filter = action.filter.clone();
1515

crates/toasty/src/engine/exec/get_by_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::driver::Rows;
33
use toasty_core::{driver::operation, stmt::ValueStream};
44

55
impl Exec<'_> {
6-
pub(super) async fn action_get_by_key2(&mut self, action: &plan::GetByKey2) -> Result<()> {
6+
pub(super) async fn action_get_by_key(&mut self, action: &plan::GetByKey) -> Result<()> {
77
let keys = self
88
.vars
99
.load(action.input)

crates/toasty/src/engine/exec/query_pk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
use toasty_core::driver::operation;
66

77
impl Exec<'_> {
8-
pub(super) async fn action_query_pk2(&mut self, action: &plan::QueryPk2) -> Result<()> {
8+
pub(super) async fn action_query_pk(&mut self, action: &plan::QueryPk) -> Result<()> {
99
let mut pk_filter = action.pk_filter.clone();
1010

1111
if let Some(input) = &action.input {

crates/toasty/src/engine/exec/rmw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ use toasty_core::{
1111
};
1212

1313
impl Exec<'_> {
14-
pub(super) async fn action_read_modify_write2(
14+
pub(super) async fn action_read_modify_write(
1515
&mut self,
16-
action: &plan::ReadModifyWrite2,
16+
action: &plan::ReadModifyWrite,
1717
) -> Result<()> {
1818
assert!(action.input.is_empty(), "TODO");
1919

crates/toasty/src/engine/exec/set_var.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
use toasty_core::driver::Rows;
66

77
impl Exec<'_> {
8-
pub(super) fn action_set_var2(&mut self, action: &plan::SetVar2) -> Result<()> {
8+
pub(super) fn action_set_var(&mut self, action: &plan::SetVar) -> Result<()> {
99
// Store the projected stream to the output variable
1010
self.vars.store(
1111
action.output.var,

crates/toasty/src/engine/index.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,17 @@ use toasty_core::{
1313
*/
1414

1515
impl Engine {
16-
pub(crate) fn plan_index_path2<'a>(&'a self, stmt: &stmt::Statement) -> IndexPlan<'a> {
16+
pub(crate) fn plan_index_path<'a>(&'a self, stmt: &stmt::Statement) -> IndexPlan<'a> {
1717
let cx = self.expr_cx();
1818
let cx = cx.scope(stmt);
19-
// Get a handle to the expression target so it can be passed into plan_index_path
19+
// Get a handle to the expression target so it can be passed into the planner
2020
let target = cx.target();
2121
let stmt::ExprTarget::Table(table) = target else {
2222
todo!("target={target:#?}")
2323
};
2424

2525
// Get the statement filter
26-
let Some(filter) = stmt.filter() else {
27-
todo!("stmt={stmt:#?}")
28-
};
29-
30-
self.plan_index_path(cx, table, filter)
31-
}
32-
33-
pub(crate) fn plan_index_path<'a, 'stmt>(
34-
&'a self,
35-
cx: stmt::ExprContext<'stmt>,
36-
table: &'stmt Table,
37-
filter: &'stmt stmt::Filter,
38-
) -> IndexPlan<'a> {
39-
let filter = filter.expr.as_ref().expect("TODO");
26+
let filter = stmt.filter_expr_unwrap();
4027

4128
let mut index_planner = IndexPlanner {
4229
cx,

0 commit comments

Comments
 (0)