@@ -61,8 +61,8 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
61
61
node : & DfNodeType ,
62
62
predicates : & [ ArcDfPredNode ] ,
63
63
children_stats : & [ Option < & Statistics > ] ,
64
- context : Option < RelNodeContext > ,
65
- optimizer : Option < & CascadesOptimizer < DfNodeType > > ,
64
+ context : RelNodeContext ,
65
+ optimizer : & CascadesOptimizer < DfNodeType > ,
66
66
) -> Cost {
67
67
self . base_model
68
68
. compute_operation_cost ( node, predicates, children_stats, context, optimizer)
@@ -73,11 +73,9 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
73
73
node : & DfNodeType ,
74
74
predicates : & [ ArcDfPredNode ] ,
75
75
children_stats : & [ & Statistics ] ,
76
- context : Option < RelNodeContext > ,
77
- optimizer : Option < & CascadesOptimizer < DfNodeType > > ,
76
+ context : RelNodeContext ,
77
+ optimizer : & CascadesOptimizer < DfNodeType > ,
78
78
) -> Statistics {
79
- let context = context. as_ref ( ) ;
80
- let optimizer = optimizer. as_ref ( ) ;
81
79
let row_cnts = children_stats
82
80
. iter ( )
83
81
. map ( |child| DfCostModel :: row_cnt ( child) )
@@ -100,12 +98,8 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
100
98
DfCostModel :: stat ( row_cnt)
101
99
}
102
100
DfNodeType :: PhysicalFilter => {
103
- let output_schema = optimizer
104
- . unwrap ( )
105
- . get_schema_of ( context. unwrap ( ) . group_id . into ( ) ) ;
106
- let output_column_ref = optimizer
107
- . unwrap ( )
108
- . get_column_ref_of ( context. unwrap ( ) . group_id . into ( ) ) ;
101
+ let output_schema = optimizer. get_schema_of ( context. group_id . into ( ) ) ;
102
+ let output_column_ref = optimizer. get_column_ref_of ( context. group_id . into ( ) ) ;
109
103
let row_cnt = self . stats . get_filter_row_cnt (
110
104
row_cnts[ 0 ] ,
111
105
output_schema,
@@ -115,18 +109,12 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
115
109
DfCostModel :: stat ( row_cnt)
116
110
}
117
111
DfNodeType :: PhysicalNestedLoopJoin ( join_typ) => {
118
- let output_schema = optimizer
119
- . unwrap ( )
120
- . get_schema_of ( context. unwrap ( ) . group_id . into ( ) ) ;
121
- let output_column_ref = optimizer
122
- . unwrap ( )
123
- . get_column_ref_of ( context. unwrap ( ) . group_id . into ( ) ) ;
124
- let left_column_ref = optimizer
125
- . unwrap ( )
126
- . get_column_ref_of ( context. unwrap ( ) . children_group_ids [ 0 ] . into ( ) ) ;
127
- let right_column_ref = optimizer
128
- . unwrap ( )
129
- . get_column_ref_of ( context. unwrap ( ) . children_group_ids [ 1 ] . into ( ) ) ;
112
+ let output_schema = optimizer. get_schema_of ( context. group_id . into ( ) ) ;
113
+ let output_column_ref = optimizer. get_column_ref_of ( context. group_id . into ( ) ) ;
114
+ let left_column_ref =
115
+ optimizer. get_column_ref_of ( context. children_group_ids [ 0 ] . into ( ) ) ;
116
+ let right_column_ref =
117
+ optimizer. get_column_ref_of ( context. children_group_ids [ 1 ] . into ( ) ) ;
130
118
let row_cnt = self . stats . get_nlj_row_cnt (
131
119
* join_typ,
132
120
row_cnts[ 0 ] ,
@@ -140,18 +128,12 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
140
128
DfCostModel :: stat ( row_cnt)
141
129
}
142
130
DfNodeType :: PhysicalHashJoin ( join_typ) => {
143
- let output_schema = optimizer
144
- . unwrap ( )
145
- . get_schema_of ( context. unwrap ( ) . group_id . into ( ) ) ;
146
- let output_column_ref = optimizer
147
- . unwrap ( )
148
- . get_column_ref_of ( context. unwrap ( ) . group_id . into ( ) ) ;
149
- let left_column_ref = optimizer
150
- . unwrap ( )
151
- . get_column_ref_of ( context. unwrap ( ) . children_group_ids [ 0 ] . into ( ) ) ;
152
- let right_column_ref = optimizer
153
- . unwrap ( )
154
- . get_column_ref_of ( context. unwrap ( ) . children_group_ids [ 1 ] . into ( ) ) ;
131
+ let output_schema = optimizer. get_schema_of ( context. group_id . into ( ) ) ;
132
+ let output_column_ref = optimizer. get_column_ref_of ( context. group_id . into ( ) ) ;
133
+ let left_column_ref =
134
+ optimizer. get_column_ref_of ( context. children_group_ids [ 0 ] . into ( ) ) ;
135
+ let right_column_ref =
136
+ optimizer. get_column_ref_of ( context. children_group_ids [ 1 ] . into ( ) ) ;
155
137
let row_cnt = self . stats . get_hash_join_row_cnt (
156
138
* join_typ,
157
139
row_cnts[ 0 ] ,
@@ -166,9 +148,7 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
166
148
DfCostModel :: stat ( row_cnt)
167
149
}
168
150
DfNodeType :: PhysicalAgg => {
169
- let output_column_ref = optimizer
170
- . unwrap ( )
171
- . get_column_ref_of ( context. unwrap ( ) . group_id . into ( ) ) ;
151
+ let output_column_ref = optimizer. get_column_ref_of ( context. group_id . into ( ) ) ;
172
152
let row_cnt = self
173
153
. stats
174
154
. get_agg_row_cnt ( predicates[ 1 ] . clone ( ) , output_column_ref) ;
@@ -178,8 +158,8 @@ impl CostModel<DfNodeType, NaiveMemo<DfNodeType>> for AdvancedCostModel {
178
158
node,
179
159
predicates,
180
160
children_stats,
181
- context. cloned ( ) ,
182
- optimizer. copied ( ) ,
161
+ context,
162
+ optimizer,
183
163
) ,
184
164
}
185
165
}
0 commit comments