@@ -474,7 +474,7 @@ impl CostModelStorageLayer for BackendManager {
474474 & self ,
475475 expr_id : ExprId ,
476476 epoch_id : EpochId ,
477- ) -> StorageResult < ( Option < Cost > , Option < i32 > ) > {
477+ ) -> StorageResult < ( Option < Cost > , Option < f32 > ) > {
478478 let cost = PlanCost :: find ( )
479479 . filter ( plan_cost:: Column :: PhysicalExpressionId . eq ( expr_id) )
480480 . filter ( plan_cost:: Column :: EpochId . eq ( epoch_id) )
@@ -486,8 +486,8 @@ impl CostModelStorageLayer for BackendManager {
486486 }
487487
488488 let real_cost = cost. as_ref ( ) . and_then ( |c| c. cost . as_ref ( ) ) . map ( |c| Cost {
489- compute_cost : c. get ( "compute_cost" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as i32 ,
490- io_cost : c. get ( "io_cost" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as i32 ,
489+ compute_cost : c. get ( "compute_cost" ) . unwrap ( ) . as_f64 ( ) . unwrap ( ) ,
490+ io_cost : c. get ( "io_cost" ) . unwrap ( ) . as_f64 ( ) . unwrap ( ) ,
491491 } ) ;
492492
493493 Ok ( ( real_cost, cost. unwrap ( ) . estimated_statistic ) )
@@ -498,7 +498,7 @@ impl CostModelStorageLayer for BackendManager {
498498 /// Each record in the `plan_cost` table can contain either the cost or the estimated statistic
499499 /// or both, but never neither.
500500 /// The name can be misleading, since it can also return the estimated statistic.
501- async fn get_cost ( & self , expr_id : ExprId ) -> StorageResult < ( Option < Cost > , Option < i32 > ) > {
501+ async fn get_cost ( & self , expr_id : ExprId ) -> StorageResult < ( Option < Cost > , Option < f32 > ) > {
502502 let cost = PlanCost :: find ( )
503503 . filter ( plan_cost:: Column :: PhysicalExpressionId . eq ( expr_id) )
504504 . order_by_desc ( plan_cost:: Column :: EpochId )
@@ -510,8 +510,8 @@ impl CostModelStorageLayer for BackendManager {
510510 }
511511
512512 let real_cost = cost. as_ref ( ) . and_then ( |c| c. cost . as_ref ( ) ) . map ( |c| Cost {
513- compute_cost : c. get ( "compute_cost" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as i32 ,
514- io_cost : c. get ( "io_cost" ) . unwrap ( ) . as_i64 ( ) . unwrap ( ) as i32 ,
513+ compute_cost : c. get ( "compute_cost" ) . unwrap ( ) . as_f64 ( ) . unwrap ( ) ,
514+ io_cost : c. get ( "io_cost" ) . unwrap ( ) . as_f64 ( ) . unwrap ( ) ,
515515 } ) ;
516516
517517 Ok ( ( real_cost, cost. unwrap ( ) . estimated_statistic ) )
@@ -524,7 +524,7 @@ impl CostModelStorageLayer for BackendManager {
524524 & self ,
525525 physical_expression_id : ExprId ,
526526 cost : Option < Cost > ,
527- estimated_statistic : Option < i32 > ,
527+ estimated_statistic : Option < f32 > ,
528528 epoch_id : EpochId ,
529529 ) -> StorageResult < ( ) > {
530530 assert ! ( cost. is_some( ) || estimated_statistic. is_some( ) ) ;
@@ -801,10 +801,10 @@ mod tests {
801801 . store_cost (
802802 expr_id,
803803 Some ( Cost {
804- compute_cost : 42 ,
805- io_cost : 42 ,
804+ compute_cost : 42.0 ,
805+ io_cost : 42.0 ,
806806 } ) ,
807- Some ( 42 ) ,
807+ Some ( 42.0 ) ,
808808 versioned_stat_res[ 0 ] . epoch_id ,
809809 )
810810 . await
@@ -1004,10 +1004,10 @@ mod tests {
10041004 . unwrap ( ) ;
10051005 let physical_expression_id = 1 ;
10061006 let cost = Cost {
1007- compute_cost : 42 ,
1008- io_cost : 42 ,
1007+ compute_cost : 42.0 ,
1008+ io_cost : 42.0 ,
10091009 } ;
1010- let mut estimated_statistic = 42 ;
1010+ let mut estimated_statistic = 42.0 ;
10111011 backend_manager
10121012 . store_cost (
10131013 physical_expression_id,
@@ -1028,12 +1028,9 @@ mod tests {
10281028 costs[ 1 ] . cost,
10291029 Some ( json!( { "compute_cost" : cost. compute_cost, "io_cost" : cost. io_cost} ) )
10301030 ) ;
1031- assert_eq ! (
1032- costs[ 1 ] . estimated_statistic. unwrap( ) as i32 ,
1033- estimated_statistic
1034- ) ;
1031+ assert_eq ! ( costs[ 1 ] . estimated_statistic. unwrap( ) , estimated_statistic) ;
10351032
1036- estimated_statistic = 50 ;
1033+ estimated_statistic = 50.0 ;
10371034 backend_manager
10381035 . store_cost (
10391036 physical_expression_id,
@@ -1055,7 +1052,7 @@ mod tests {
10551052 Some ( json!( { "compute_cost" : cost. compute_cost, "io_cost" : cost. io_cost} ) )
10561053 ) ;
10571054 assert_eq ! (
1058- costs[ 1 ] . estimated_statistic. unwrap( ) as i32 ,
1055+ costs[ 1 ] . estimated_statistic. unwrap( ) ,
10591056 estimated_statistic // The estimated_statistic should be update
10601057 ) ;
10611058
@@ -1074,8 +1071,8 @@ mod tests {
10741071 . unwrap ( ) ;
10751072 let physical_expression_id = 1 ;
10761073 let cost = Cost {
1077- compute_cost : 42 ,
1078- io_cost : 42 ,
1074+ compute_cost : 42.0 ,
1075+ io_cost : 42.0 ,
10791076 } ;
10801077 let _ = backend_manager
10811078 . store_cost ( physical_expression_id, Some ( cost. clone ( ) ) , None , epoch_id)
@@ -1114,7 +1111,7 @@ mod tests {
11141111 . await
11151112 . unwrap ( ) ;
11161113 let physical_expression_id = 1 ;
1117- let estimated_statistic = 42 ;
1114+ let estimated_statistic = 42.0 ;
11181115 let _ = backend_manager
11191116 . store_cost (
11201117 physical_expression_id,
@@ -1131,10 +1128,7 @@ mod tests {
11311128 assert_eq ! ( costs[ 1 ] . epoch_id, epoch_id) ;
11321129 assert_eq ! ( costs[ 1 ] . physical_expression_id, physical_expression_id) ;
11331130 assert_eq ! ( costs[ 1 ] . cost, None ) ;
1134- assert_eq ! (
1135- costs[ 1 ] . estimated_statistic. unwrap( ) as i32 ,
1136- estimated_statistic
1137- ) ;
1131+ assert_eq ! ( costs[ 1 ] . estimated_statistic. unwrap( ) , estimated_statistic) ;
11381132 println ! ( "{:?}" , costs) ;
11391133
11401134 // Retrieve physical_expression_id 1 and epoch_id 1
@@ -1147,11 +1141,11 @@ mod tests {
11471141 assert_eq ! (
11481142 res. 0 . unwrap( ) ,
11491143 Cost {
1150- compute_cost: 10 ,
1151- io_cost: 10 ,
1144+ compute_cost: 10.0 ,
1145+ io_cost: 10.0 ,
11521146 }
11531147 ) ;
1154- assert_eq ! ( res. 1 . unwrap( ) , 10 ) ;
1148+ assert_eq ! ( res. 1 . unwrap( ) , 10.0 ) ;
11551149
11561150 remove_db_file ( DATABASE_FILE ) ;
11571151 }
0 commit comments