@@ -13,13 +13,10 @@ use sea_orm::{
1313use serde_json:: json;
1414
1515use super :: catalog:: mock_catalog:: { self , MockCatalog } ;
16- use super :: interface:: { CatalogSource , EpochOption , Stat } ;
16+ use super :: interface:: { AttrId , CatalogSource , EpochId , EpochOption , ExprId , Stat , StatId } ;
1717
1818impl BackendManager {
19- fn get_description_from_attr_ids (
20- & self ,
21- attr_ids : Vec < <BackendManager as CostModelStorageLayer >:: AttrId > ,
22- ) -> String {
19+ fn get_description_from_attr_ids ( & self , attr_ids : Vec < AttrId > ) -> String {
2320 let mut attr_ids = attr_ids;
2421 attr_ids. sort ( ) ;
2522 attr_ids
@@ -31,15 +28,8 @@ impl BackendManager {
3128}
3229
3330impl CostModelStorageLayer for BackendManager {
34- type GroupId = i32 ;
35- type TableId = i32 ;
36- type AttrId = i32 ;
37- type ExprId = i32 ;
38- type EpochId = i32 ;
39- type StatId = i32 ;
40-
4131 /// TODO: documentation
42- async fn create_new_epoch ( & self , source : String , data : String ) -> StorageResult < Self :: EpochId > {
32+ async fn create_new_epoch ( & self , source : String , data : String ) -> StorageResult < EpochId > {
4333 let new_event = event:: ActiveModel {
4434 source_variant : sea_orm:: ActiveValue :: Set ( source) ,
4535 timestamp : sea_orm:: ActiveValue :: Set ( Utc :: now ( ) ) ,
@@ -51,7 +41,7 @@ impl CostModelStorageLayer for BackendManager {
5141 }
5242
5343 /// TODO: documentation
54- async fn update_stats_from_catalog ( & self , c : CatalogSource ) -> StorageResult < Self :: EpochId > {
44+ async fn update_stats_from_catalog ( & self , c : CatalogSource ) -> StorageResult < EpochId > {
5545 let transaction = self . db . begin ( ) . await ?;
5646 let source = match c {
5747 CatalogSource :: Mock => "Mock" ,
@@ -208,7 +198,7 @@ impl CostModelStorageLayer for BackendManager {
208198 & self ,
209199 stat : Stat ,
210200 epoch_option : EpochOption ,
211- ) -> StorageResult < Option < Self :: EpochId > > {
201+ ) -> StorageResult < Option < EpochId > > {
212202 let transaction = self . db . begin ( ) . await ?;
213203 // 0. Check if the stat already exists. If exists, get stat_id, else insert into statistic table.
214204 let stat_id = match stat. table_id {
@@ -353,8 +343,8 @@ impl CostModelStorageLayer for BackendManager {
353343 /// TODO: documentation
354344 async fn store_expr_stats_mappings (
355345 & self ,
356- expr_id : Self :: ExprId ,
357- stat_ids : Vec < Self :: StatId > ,
346+ expr_id : ExprId ,
347+ stat_ids : Vec < StatId > ,
358348 ) -> StorageResult < ( ) > {
359349 let to_insert_mappings = stat_ids
360350 . iter ( )
@@ -376,7 +366,7 @@ impl CostModelStorageLayer for BackendManager {
376366 & self ,
377367 table_id : i32 ,
378368 stat_type : i32 ,
379- epoch_id : Option < Self :: EpochId > ,
369+ epoch_id : Option < EpochId > ,
380370 ) -> StorageResult < Option < Json > > {
381371 match epoch_id {
382372 Some ( epoch_id) => Ok ( VersionedStatistic :: find ( )
@@ -402,9 +392,9 @@ impl CostModelStorageLayer for BackendManager {
402392 /// TODO: documentation
403393 async fn get_stats_for_attr (
404394 & self ,
405- mut attr_ids : Vec < Self :: AttrId > ,
395+ mut attr_ids : Vec < AttrId > ,
406396 stat_type : i32 ,
407- epoch_id : Option < Self :: EpochId > ,
397+ epoch_id : Option < EpochId > ,
408398 ) -> StorageResult < Option < Json > > {
409399 let attr_num = attr_ids. len ( ) as i32 ;
410400 // The description is to concat `attr_ids` using commas
@@ -440,8 +430,8 @@ impl CostModelStorageLayer for BackendManager {
440430 /// TODO: documentation
441431 async fn get_cost_analysis (
442432 & self ,
443- expr_id : Self :: ExprId ,
444- epoch_id : Self :: EpochId ,
433+ expr_id : ExprId ,
434+ epoch_id : EpochId ,
445435 ) -> StorageResult < Option < Cost > > {
446436 let cost = PlanCost :: find ( )
447437 . filter ( plan_cost:: Column :: PhysicalExpressionId . eq ( expr_id) )
@@ -457,7 +447,7 @@ impl CostModelStorageLayer for BackendManager {
457447 } ) )
458448 }
459449
460- async fn get_cost ( & self , expr_id : Self :: ExprId ) -> StorageResult < Option < Cost > > {
450+ async fn get_cost ( & self , expr_id : ExprId ) -> StorageResult < Option < Cost > > {
461451 let cost = PlanCost :: find ( )
462452 . filter ( plan_cost:: Column :: PhysicalExpressionId . eq ( expr_id) )
463453 . order_by_desc ( plan_cost:: Column :: EpochId )
@@ -475,9 +465,9 @@ impl CostModelStorageLayer for BackendManager {
475465 /// TODO: documentation
476466 async fn store_cost (
477467 & self ,
478- physical_expression_id : Self :: ExprId ,
468+ physical_expression_id : ExprId ,
479469 cost : Cost ,
480- epoch_id : Self :: EpochId ,
470+ epoch_id : EpochId ,
481471 ) -> StorageResult < ( ) > {
482472 let expr_exists = PhysicalExpression :: find_by_id ( physical_expression_id)
483473 . one ( & self . db )
0 commit comments