@@ -11,6 +11,7 @@ use crate::{
1111 constant_pred:: { ConstantPred , ConstantType } ,
1212 un_op_pred:: UnOpType ,
1313 } ,
14+ types:: TableId ,
1415 values:: Value ,
1516 } ,
1617 cost_model:: CostModelImpl ,
@@ -29,7 +30,7 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
2930 pub fn get_filter_row_cnt (
3031 & self ,
3132 child_row_cnt : EstimatedStatistic ,
32- table_id : i32 ,
33+ table_id : TableId ,
3334 cond : ArcPredicateNode ,
3435 ) -> CostModelResult < EstimatedStatistic > {
3536 let selectivity = { self . get_filter_selectivity ( cond, table_id) ? } ;
@@ -42,7 +43,7 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
4243 pub fn get_filter_selectivity (
4344 & self ,
4445 expr_tree : ArcPredicateNode ,
45- table_id : i32 ,
46+ table_id : TableId ,
4647 ) -> CostModelResult < f64 > {
4748 match & expr_tree. typ {
4849 PredicateType :: Constant ( _) => Ok ( Self :: get_constant_selectivity ( expr_tree) ) ,
@@ -112,29 +113,29 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
112113 comp_bin_op_typ : BinOpType ,
113114 left : ArcPredicateNode ,
114115 right : ArcPredicateNode ,
115- table_id : i32 ,
116+ table_id : TableId ,
116117 ) -> CostModelResult < f64 > {
117118 assert ! ( comp_bin_op_typ. is_comparison( ) ) ;
118119
119120 // I intentionally performed moves on left and right. This way, we don't accidentally use
120121 // them after this block
121- let ( col_ref_exprs , values, non_col_ref_exprs , is_left_col_ref ) =
122+ let ( attr_ref_exprs , values, non_attr_ref_exprs , is_left_attr_ref ) =
122123 self . get_semantic_nodes ( left, right, table_id) ?;
123124
124125 // Handle the different cases of semantic nodes.
125- if col_ref_exprs . is_empty ( ) {
126+ if attr_ref_exprs . is_empty ( ) {
126127 Ok ( UNIMPLEMENTED_SEL )
127- } else if col_ref_exprs . len ( ) == 1 {
128- let col_ref_expr = col_ref_exprs
128+ } else if attr_ref_exprs . len ( ) == 1 {
129+ let attr_ref_expr = attr_ref_exprs
129130 . first ( )
130- . expect ( "we just checked that col_ref_exprs .len() == 1" ) ;
131- let col_ref_idx = col_ref_expr . index ( ) ;
131+ . expect ( "we just checked that attr_ref_exprs .len() == 1" ) ;
132+ let attr_ref_idx = attr_ref_expr . index ( ) ;
132133
133134 todo ! ( )
134- } else if col_ref_exprs . len ( ) == 2 {
135+ } else if attr_ref_exprs . len ( ) == 2 {
135136 Ok ( Self :: get_default_comparison_op_selectivity ( comp_bin_op_typ) )
136137 } else {
137- unreachable ! ( "we could have at most pushed left and right into col_ref_exprs " )
138+ unreachable ! ( "we could have at most pushed left and right into attr_ref_exprs " )
138139 }
139140 }
140141
@@ -146,17 +147,17 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
146147 & self ,
147148 left : ArcPredicateNode ,
148149 right : ArcPredicateNode ,
149- table_id : i32 ,
150+ table_id : TableId ,
150151 ) -> CostModelResult < (
151152 Vec < AttributeRefPred > ,
152153 Vec < Value > ,
153154 Vec < ArcPredicateNode > ,
154155 bool ,
155156 ) > {
156- let mut col_ref_exprs = vec ! [ ] ;
157+ let mut attr_ref_exprs = vec ! [ ] ;
157158 let mut values = vec ! [ ] ;
158- let mut non_col_ref_exprs = vec ! [ ] ;
159- let is_left_col_ref ;
159+ let mut non_attr_ref_exprs = vec ! [ ] ;
160+ let is_left_attr_ref ;
160161
161162 // Recursively unwrap casts as much as we can.
162163 let mut uncasted_left = left;
@@ -201,16 +202,16 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
201202 false
202203 }
203204 PredicateType :: AttributeRef => {
204- let col_ref_expr = AttributeRefPred :: from_pred_node ( cast_expr_child)
205+ let attr_ref_expr = AttributeRefPred :: from_pred_node ( cast_expr_child)
205206 . expect ( "we already checked that the type is ColumnRef" ) ;
206- let col_ref_idx = col_ref_expr . index ( ) ;
207- cast_node = col_ref_expr . into_pred_node ( ) ;
207+ let attr_ref_idx = attr_ref_expr . index ( ) ;
208+ cast_node = attr_ref_expr . into_pred_node ( ) ;
208209 // The "invert" cast is to invert the cast so that we're casting the
209210 // non_cast_node to the column's original type.
210211 // TODO(migration): double check
211212 let invert_cast_data_type = & ( self
212213 . storage_manager
213- . get_attribute_info ( table_id, col_ref_idx as i32 ) ?
214+ . get_attribute_info ( table_id, attr_ref_idx as i32 ) ?
214215 . typ
215216 . into_data_type ( ) ) ;
216217
@@ -247,31 +248,31 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
247248 }
248249 }
249250
250- // Sort nodes into col_ref_exprs , values, and non_col_ref_exprs
251+ // Sort nodes into attr_ref_exprs , values, and non_attr_ref_exprs
251252 match uncasted_left. as_ref ( ) . typ {
252253 PredicateType :: AttributeRef => {
253- is_left_col_ref = true ;
254- col_ref_exprs . push (
254+ is_left_attr_ref = true ;
255+ attr_ref_exprs . push (
255256 AttributeRefPred :: from_pred_node ( uncasted_left)
256257 . expect ( "we already checked that the type is ColumnRef" ) ,
257258 ) ;
258259 }
259260 PredicateType :: Constant ( _) => {
260- is_left_col_ref = false ;
261+ is_left_attr_ref = false ;
261262 values. push (
262263 ConstantPred :: from_pred_node ( uncasted_left)
263264 . expect ( "we already checked that the type is Constant" )
264265 . value ( ) ,
265266 )
266267 }
267268 _ => {
268- is_left_col_ref = false ;
269- non_col_ref_exprs . push ( uncasted_left) ;
269+ is_left_attr_ref = false ;
270+ non_attr_ref_exprs . push ( uncasted_left) ;
270271 }
271272 }
272273 match uncasted_right. as_ref ( ) . typ {
273274 PredicateType :: AttributeRef => {
274- col_ref_exprs . push (
275+ attr_ref_exprs . push (
275276 AttributeRefPred :: from_pred_node ( uncasted_right)
276277 . expect ( "we already checked that the type is ColumnRef" ) ,
277278 ) ;
@@ -282,12 +283,12 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
282283 . value ( ) ,
283284 ) ,
284285 _ => {
285- non_col_ref_exprs . push ( uncasted_right) ;
286+ non_attr_ref_exprs . push ( uncasted_right) ;
286287 }
287288 }
288289
289- assert ! ( col_ref_exprs . len( ) + values. len( ) + non_col_ref_exprs . len( ) == 2 ) ;
290- Ok ( ( col_ref_exprs , values, non_col_ref_exprs , is_left_col_ref ) )
290+ assert ! ( attr_ref_exprs . len( ) + values. len( ) + non_attr_ref_exprs . len( ) == 2 ) ;
291+ Ok ( ( attr_ref_exprs , values, non_attr_ref_exprs , is_left_attr_ref ) )
291292 }
292293
293294 /// The default selectivity of a comparison expression
0 commit comments