Skip to content

Commit

Permalink
make MemoExt a member field of the cost model
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Nov 18, 2024
1 parent e730925 commit 625e129
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion optd-cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
nodes::{ArcPredicateNode, PhysicalNodeType},
types::{AttrId, EpochId, ExprId, TableId},
},
memo_ext::MemoExt,
storage::CostModelStorageManager,
ComputeCostContext, Cost, CostModel, CostModelResult, EstimatedStatistic, StatValue,
};
Expand All @@ -20,22 +21,25 @@ use crate::{
pub struct CostModelImpl<S: CostModelStorageLayer> {
storage_manager: CostModelStorageManager<S>,
default_catalog_source: CatalogSource,
_memo: Arc<dyn MemoExt>,
}

impl<S: CostModelStorageLayer> CostModelImpl<S> {
/// TODO: documentation
pub fn new(
storage_manager: CostModelStorageManager<S>,
default_catalog_source: CatalogSource,
memo: Arc<dyn MemoExt>,
) -> Self {
Self {
storage_manager,
default_catalog_source,
_memo: memo,
}
}
}

impl<S: CostModelStorageLayer + std::marker::Sync + 'static> CostModel for CostModelImpl<S> {
impl<S: CostModelStorageLayer + Sync + 'static> CostModel for CostModelImpl<S> {
fn compute_operation_cost(
&self,
node: &PhysicalNodeType,
Expand Down
2 changes: 1 addition & 1 deletion optd-cost-model/src/memo_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::common::{
types::GroupId,
};

pub trait MemoExt {
pub trait MemoExt: Send + Sync + 'static {
fn get_schema(&self, group_id: GroupId) -> Schema;
fn get_column_ref(&self, group_id: GroupId) -> GroupAttrRefs;
fn get_attribute_info(&self, group_id: GroupId, attr_ref_idx: u64) -> Attribute;
Expand Down

0 comments on commit 625e129

Please sign in to comment.