-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate memo and cost model storage_layer trait
- Loading branch information
1 parent
436ffd4
commit 6c3a890
Showing
6 changed files
with
261 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#![allow(dead_code, unused_imports, unused_variables)] | ||
|
||
use crate::memo_storage_layer::MemoStorageLayer; | ||
use crate::orm_manager::ORMManager; | ||
|
||
impl MemoStorageLayer for ORMManager { | ||
async fn get_group_winner_from_group_id( | ||
&self, | ||
group_id: i32, | ||
) -> crate::StorageResult<Option<crate::entities::physical_expression::ActiveModel>> { | ||
todo!() | ||
} | ||
|
||
async fn add_new_expr( | ||
&mut self, | ||
expr: crate::memo_storage_layer::Expression, | ||
) -> crate::StorageResult<(crate::GroupId, crate::ExprId)> { | ||
todo!() | ||
} | ||
|
||
async fn add_expr_to_group( | ||
&mut self, | ||
expr: crate::memo_storage_layer::Expression, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<Option<crate::ExprId>> { | ||
todo!() | ||
} | ||
|
||
async fn get_group_id(&self, expr_id: crate::ExprId) -> crate::StorageResult<crate::GroupId> { | ||
todo!() | ||
} | ||
|
||
async fn get_expr_memoed( | ||
&self, | ||
expr_id: crate::ExprId, | ||
) -> crate::StorageResult<crate::memo_storage_layer::Expression> { | ||
todo!() | ||
} | ||
|
||
async fn get_all_group_ids(&self) -> crate::StorageResult<Vec<crate::GroupId>> { | ||
todo!() | ||
} | ||
|
||
async fn get_group( | ||
&self, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<crate::entities::cascades_group::ActiveModel> { | ||
todo!() | ||
} | ||
|
||
async fn update_group_winner( | ||
&mut self, | ||
group_id: crate::GroupId, | ||
latest_winner: Option<crate::ExprId>, | ||
) -> crate::StorageResult<()> { | ||
todo!() | ||
} | ||
|
||
async fn get_all_exprs_in_group( | ||
&self, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<Vec<crate::ExprId>> { | ||
todo!() | ||
} | ||
|
||
async fn get_group_info( | ||
&self, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<&Option<crate::ExprId>> { | ||
todo!() | ||
} | ||
|
||
async fn get_predicate_binding( | ||
&self, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<Option<crate::memo_storage_layer::Expression>> { | ||
todo!() | ||
} | ||
|
||
async fn try_get_predicate_binding( | ||
&self, | ||
group_id: crate::GroupId, | ||
) -> crate::StorageResult<Option<crate::memo_storage_layer::Expression>> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#![allow(dead_code, unused_imports)] | ||
|
||
use crate::entities::cascades_group; | ||
use crate::entities::event::Model as event_model; | ||
use crate::entities::logical_expression; | ||
use crate::entities::physical_expression; | ||
use crate::{EpochId, ExprId, StatId, StorageResult}; | ||
use sea_orm::*; | ||
use sea_orm_migration::prelude::*; | ||
use serde_json::json; | ||
use std::sync::Arc; | ||
|
||
pub enum CatalogSource { | ||
Iceberg(), | ||
} | ||
|
||
pub trait CostModelStorageLayer { | ||
// TODO: Change EpochId to event::Model::epoch_id | ||
async fn create_new_epoch(&mut self, source: String, data: String) -> StorageResult<EpochId>; | ||
|
||
async fn update_stats_from_catalog( | ||
&self, | ||
c: CatalogSource, | ||
epoch_id: EpochId, | ||
) -> StorageResult<()>; | ||
|
||
// i32 in `stats:i32` is a placeholder for the stats type | ||
async fn update_stats(&self, stats: i32, epoch_id: EpochId) -> StorageResult<()>; | ||
|
||
async fn store_cost(&self, expr_id: ExprId, cost: i32, epoch_id: EpochId) -> StorageResult<()>; | ||
|
||
async fn store_expr_stats_mappings( | ||
&self, | ||
expr_id: ExprId, | ||
stat_ids: Vec<StatId>, | ||
) -> StorageResult<()>; | ||
|
||
/// Get the statistics for a given table. | ||
/// | ||
/// If `epoch_id` is None, it will return the latest statistics. | ||
async fn get_stats_for_table( | ||
&self, | ||
table_id: i32, | ||
stat_type: i32, | ||
epoch_id: Option<EpochId>, | ||
) -> StorageResult<Option<f32>>; | ||
|
||
/// Get the statistics for a given attribute. | ||
/// | ||
/// If `epoch_id` is None, it will return the latest statistics. | ||
async fn get_stats_for_attr( | ||
&self, | ||
attr_id: i32, | ||
stat_type: i32, | ||
epoch_id: Option<EpochId>, | ||
) -> StorageResult<Option<f32>>; | ||
|
||
/// Get the joint statistics for a list of attributes. | ||
/// | ||
/// If `epoch_id` is None, it will return the latest statistics. | ||
async fn get_stats_for_attrs( | ||
&self, | ||
attr_ids: Vec<i32>, | ||
stat_type: i32, | ||
epoch_id: Option<EpochId>, | ||
) -> StorageResult<Option<f32>>; | ||
|
||
async fn get_cost_analysis( | ||
&self, | ||
expr_id: ExprId, | ||
epoch_id: EpochId, | ||
) -> StorageResult<Option<i32>>; | ||
|
||
async fn get_cost(&self, expr_id: ExprId) -> StorageResult<Option<i32>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#![allow(dead_code, unused_imports, unused_variables)] | ||
|
||
use crate::cost_model_storage_layer::CostModelStorageLayer; | ||
use crate::memo_storage_layer::MemoStorageLayer; | ||
use crate::orm_manager::ORMManager; | ||
|
||
impl CostModelStorageLayer for ORMManager { | ||
async fn create_new_epoch( | ||
&mut self, | ||
source: String, | ||
data: String, | ||
) -> crate::StorageResult<crate::EpochId> { | ||
todo!() | ||
} | ||
|
||
async fn update_stats_from_catalog( | ||
&self, | ||
c: crate::cost_model_storage_layer::CatalogSource, | ||
epoch_id: crate::EpochId, | ||
) -> crate::StorageResult<()> { | ||
todo!() | ||
} | ||
|
||
async fn update_stats(&self, stats: i32, epoch_id: crate::EpochId) -> crate::StorageResult<()> { | ||
todo!() | ||
} | ||
|
||
async fn store_cost( | ||
&self, | ||
expr_id: crate::ExprId, | ||
cost: i32, | ||
epoch_id: crate::EpochId, | ||
) -> crate::StorageResult<()> { | ||
todo!() | ||
} | ||
|
||
async fn store_expr_stats_mappings( | ||
&self, | ||
expr_id: crate::ExprId, | ||
stat_ids: Vec<crate::StatId>, | ||
) -> crate::StorageResult<()> { | ||
todo!() | ||
} | ||
|
||
async fn get_stats_for_table( | ||
&self, | ||
table_id: i32, | ||
stat_type: i32, | ||
epoch_id: Option<crate::EpochId>, | ||
) -> crate::StorageResult<Option<f32>> { | ||
todo!() | ||
} | ||
|
||
async fn get_stats_for_attr( | ||
&self, | ||
attr_id: i32, | ||
stat_type: i32, | ||
epoch_id: Option<crate::EpochId>, | ||
) -> crate::StorageResult<Option<f32>> { | ||
todo!() | ||
} | ||
|
||
async fn get_stats_for_attrs( | ||
&self, | ||
attr_ids: Vec<i32>, | ||
stat_type: i32, | ||
epoch_id: Option<crate::EpochId>, | ||
) -> crate::StorageResult<Option<f32>> { | ||
todo!() | ||
} | ||
|
||
async fn get_cost_analysis( | ||
&self, | ||
expr_id: crate::ExprId, | ||
epoch_id: crate::EpochId, | ||
) -> crate::StorageResult<Option<i32>> { | ||
todo!() | ||
} | ||
|
||
async fn get_cost(&self, expr_id: crate::ExprId) -> crate::StorageResult<Option<i32>> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.