Skip to content

Commit f5793f6

Browse files
committed
chore: codefmt
1 parent ed9f75e commit f5793f6

7 files changed

Lines changed: 27 additions & 50 deletions

File tree

src/execution/ddl/create_index.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,9 @@ impl CreateIndex {
107107
while arena.next_tuple(self.input)? {
108108
let (value, tuple_pk) = {
109109
let tuple = arena.result_tuple();
110-
let Some(value) = DataValue::values_to_tuple(Projection::projection(
111-
tuple,
112-
&column_exprs,
113-
&self.input_schema,
114-
)?) else {
110+
let Some(value) =
111+
DataValue::values_to_tuple(Projection::projection(tuple, &column_exprs)?)
112+
else {
115113
continue;
116114
};
117115
let Some(tuple_pk) = tuple.pk.clone() else {

src/execution/dml/analyze.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::planner::operator::analyze::AnalyzeOperator;
2323
use crate::planner::LogicalPlan;
2424
use crate::storage::{StatisticsMetaCache, Transaction};
2525
use crate::types::index::IndexId;
26-
use crate::types::tuple::SchemaRef;
2726
use crate::types::value::{DataValue, Utf8Type};
2827
use itertools::Itertools;
2928
use sqlparser::ast::CharLengthUnits;
@@ -34,7 +33,6 @@ const DEFAULT_NUM_OF_BUCKETS: usize = 100;
3433

3534
pub struct Analyze {
3635
table_name: TableName,
37-
input_schema: SchemaRef,
3836
input_plan: LogicalPlan,
3937
input: Option<ExecId>,
4038
histogram_buckets: Option<usize>,
@@ -48,13 +46,12 @@ impl From<(AnalyzeOperator, LogicalPlan)> for Analyze {
4846
index_metas,
4947
histogram_buckets,
5048
},
51-
mut input,
49+
input,
5250
): (AnalyzeOperator, LogicalPlan),
5351
) -> Self {
5452
let _ = index_metas;
5553
Analyze {
5654
table_name,
57-
input_schema: input.output_schema().clone(),
5855
input_plan: input,
5956
input: None,
6057
histogram_buckets,
@@ -108,7 +105,7 @@ impl Analyze {
108105
while arena.next_tuple(input)? {
109106
let tuple = arena.result_tuple();
110107
for State { exprs, builder, .. } in builders.iter_mut() {
111-
let values = Projection::projection(tuple, exprs, &self.input_schema)?;
108+
let values = Projection::projection(tuple, exprs)?;
112109

113110
if values.len() == 1 {
114111
builder.append(&values[0])?;

src/execution/dml/delete.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,20 @@ use crate::planner::operator::delete::DeleteOperator;
2121
use crate::planner::LogicalPlan;
2222
use crate::storage::Transaction;
2323
use crate::types::index::{Index, IndexId, IndexType};
24-
use crate::types::tuple::SchemaRef;
2524
use crate::types::tuple_builder::TupleBuilder;
2625
use crate::types::value::DataValue;
2726
use std::collections::HashMap;
2827

2928
pub struct Delete {
3029
table_name: TableName,
31-
input_schema: SchemaRef,
3230
input_plan: LogicalPlan,
3331
input: Option<ExecId>,
3432
}
3533

3634
impl From<(DeleteOperator, LogicalPlan)> for Delete {
37-
fn from((DeleteOperator { table_name, .. }, mut input): (DeleteOperator, LogicalPlan)) -> Self {
35+
fn from((DeleteOperator { table_name, .. }, input): (DeleteOperator, LogicalPlan)) -> Self {
3836
Delete {
3937
table_name,
40-
input_schema: input.output_schema().clone(),
4138
input_plan: input,
4239
input: None,
4340
}
@@ -83,22 +80,18 @@ impl Delete {
8380
let tuple = arena.result_tuple().clone();
8481
for index_meta in table.indexes() {
8582
if let Some(Value { exprs, values, .. }) = indexes.get_mut(&index_meta.id) {
86-
let Some(data_value) = DataValue::values_to_tuple(Projection::projection(
87-
&tuple,
88-
exprs,
89-
&self.input_schema,
90-
)?) else {
83+
let Some(data_value) =
84+
DataValue::values_to_tuple(Projection::projection(&tuple, exprs)?)
85+
else {
9186
continue;
9287
};
9388
values.push(data_value);
9489
} else {
9590
let mut values = Vec::with_capacity(table.indexes().len());
9691
let exprs = index_meta.column_exprs(table)?;
97-
let Some(data_value) = DataValue::values_to_tuple(Projection::projection(
98-
&tuple,
99-
&exprs,
100-
&self.input_schema,
101-
)?) else {
92+
let Some(data_value) =
93+
DataValue::values_to_tuple(Projection::projection(&tuple, &exprs)?)
94+
else {
10295
continue;
10396
};
10497
values.push(data_value);

src/execution/dml/insert.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ impl Insert {
111111
return Err(DatabaseError::not_null());
112112
}
113113

114-
let table_schema = table_catalog.schema_ref();
115114
let mut index_metas = Vec::new();
116115
for index_meta in table_catalog.indexes() {
117116
let exprs = index_meta.column_exprs(&table_catalog)?;
@@ -156,7 +155,7 @@ impl Insert {
156155
let tuple = Tuple::new(Some(pk), values);
157156

158157
for (index_meta, exprs) in index_metas.iter() {
159-
let values = Projection::projection(&tuple, exprs, table_schema.as_slice())?;
158+
let values = Projection::projection(&tuple, exprs)?;
160159
let Some(value) = DataValue::values_to_tuple(values) else {
161160
continue;
162161
};

src/execution/dml/update.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl Update {
112112

113113
let old_pk = tuple.pk.clone().ok_or(DatabaseError::PrimaryKeyNotFound)?;
114114
for (index_meta, exprs) in index_metas.iter() {
115-
let values = Projection::projection(&tuple, exprs, &self.input_schema)?;
115+
let values = Projection::projection(&tuple, exprs)?;
116116
let Some(value) = DataValue::values_to_tuple(values) else {
117117
continue;
118118
};
@@ -141,7 +141,7 @@ impl Update {
141141
is_overwrite = false;
142142
}
143143
for (index_meta, exprs) in index_metas.iter() {
144-
let values = Projection::projection(&tuple, exprs, &self.input_schema)?;
144+
let values = Projection::projection(&tuple, exprs)?;
145145
let Some(value) = DataValue::values_to_tuple(values) else {
146146
continue;
147147
};

src/execution/dql/join/nested_loop_join.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,17 @@ use crate::expression::ScalarExpression;
2424
use crate::planner::operator::join::{JoinCondition, JoinOperator, JoinType};
2525
use crate::planner::LogicalPlan;
2626
use crate::storage::Transaction;
27-
use crate::types::tuple::{Schema, SchemaRef, SplitTupleRef, Tuple};
27+
use crate::types::tuple::{Schema, SplitTupleRef, Tuple};
2828
use crate::types::value::DataValue;
2929
use fixedbitset::FixedBitSet;
3030
use itertools::Itertools;
31-
use std::sync::Arc;
3231

3332
/// Equivalent condition
3433
struct EqualCondition {
3534
on_left_keys: Vec<ScalarExpression>,
3635
on_right_keys: Vec<ScalarExpression>,
37-
left_schema: SchemaRef,
38-
right_schema: SchemaRef,
36+
left_len: usize,
37+
right_len: usize,
3938
}
4039

4140
impl EqualCondition {
@@ -45,17 +44,17 @@ impl EqualCondition {
4544
fn new(
4645
on_left_keys: Vec<ScalarExpression>,
4746
on_right_keys: Vec<ScalarExpression>,
48-
left_schema: Arc<Schema>,
49-
right_schema: Arc<Schema>,
47+
left_schema: &Schema,
48+
right_schema: &Schema,
5049
) -> EqualCondition {
5150
if !on_left_keys.is_empty() && on_left_keys.len() != on_right_keys.len() {
5251
unreachable!("Unexpected join on condition.")
5352
}
5453
EqualCondition {
5554
on_left_keys,
5655
on_right_keys,
57-
left_schema,
58-
right_schema,
56+
left_len: left_schema.len(),
57+
right_len: right_schema.len(),
5958
}
6059
}
6160

@@ -66,10 +65,8 @@ impl EqualCondition {
6665
if self.on_left_keys.is_empty() {
6766
return Ok(true);
6867
}
69-
let left_values =
70-
Projection::projection(left_tuple, &self.on_left_keys, &self.left_schema)?;
71-
let right_values =
72-
Projection::projection(right_tuple, &self.on_right_keys, &self.right_schema)?;
68+
let left_values = Projection::projection(left_tuple, &self.on_left_keys)?;
69+
let right_values = Projection::projection(right_tuple, &self.on_right_keys)?;
7370

7471
Ok(left_values == right_values)
7572
}
@@ -141,12 +138,7 @@ impl From<(JoinOperator, LogicalPlan, LogicalPlan)> for NestedLoopJoin {
141138
std::mem::swap(&mut left_schema, &mut right_schema);
142139
}
143140

144-
let eq_cond = EqualCondition::new(
145-
on_left_keys,
146-
on_right_keys,
147-
left_schema.clone(),
148-
right_schema.clone(),
149-
);
141+
let eq_cond = EqualCondition::new(on_left_keys, on_right_keys, &left_schema, &right_schema);
150142

151143
NestedLoopJoin {
152144
left_input_plan: left_input,
@@ -330,7 +322,7 @@ impl NestedLoopJoin {
330322
right_bitmap = Some(bits);
331323
}
332324
}
333-
let right_schema_len = self.eq_cond.right_schema.len();
325+
let right_schema_len = self.eq_cond.right_len;
334326
let tuple = match self.ty {
335327
JoinType::LeftOuter | JoinType::RightOuter | JoinType::Full
336328
if !active_left.has_matched =>
@@ -374,7 +366,7 @@ impl NestedLoopJoin {
374366
right_emit_index += 1;
375367

376368
if !right_bitmap.contains(idx) {
377-
let mut values = vec![DataValue::Null; self.eq_cond.left_schema.len()];
369+
let mut values = vec![DataValue::Null; self.eq_cond.left_len];
378370
values.append(&mut right_tuple.values);
379371
self.state = NestedLoopJoinState::EmitRightUnmatched {
380372
right_input,

src/execution/dql/projection.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use crate::catalog::ColumnRef;
1615
use crate::errors::DatabaseError;
1716
use crate::execution::{build_read, ExecArena, ExecId, ExecNode, ExecutionCaches, ExecutorNode};
1817
use crate::expression::ScalarExpression;
@@ -68,7 +67,6 @@ impl Projection {
6867
pub fn projection(
6968
tuple: &Tuple,
7069
exprs: &[ScalarExpression],
71-
_schema: &[ColumnRef],
7270
) -> Result<Vec<DataValue>, DatabaseError> {
7371
let mut values = Vec::with_capacity(exprs.len());
7472

0 commit comments

Comments
 (0)