Skip to content

Commit

Permalink
add storage part
Browse files Browse the repository at this point in the history
  • Loading branch information
lanlou1554 committed Nov 13, 2024
1 parent c4ab846 commit b7034ae
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions optd-cost-model/src/common/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ impl std::fmt::Display for PhysicalNodeType {
pub enum PredicateType {
List,
Constant(ConstantType),
ColumnRef,
ExternColumnRef,
AttributeRef,
ExternAttributeRef,
UnOp(UnOpType),
BinOp(BinOpType),
LogOp(LogOpType),
Expand Down
10 changes: 7 additions & 3 deletions optd-cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ use crate::{
nodes::{ArcPredicateNode, PhysicalNodeType},
types::ExprId,
},
storage::CostModelStorageManager,
ComputeCostContext, CostModel, CostModelResult, EstimatedStatistic,
};

pub struct CostModelImpl<CMSL: CostModelStorageLayer> {
backend_manager: Arc<CMSL>,
storage_manager: CostModelStorageManager<CMSL>,
default_catalog_source: CatalogSource,
}

impl<CMSL: CostModelStorageLayer> CostModelImpl<CMSL> {
pub fn new(backend_manager: Arc<CMSL>, default_catalog_source: CatalogSource) -> Self {
pub fn new(
storage_manager: CostModelStorageManager<CMSL>,
default_catalog_source: CatalogSource,
) -> Self {
Self {
backend_manager,
storage_manager,
default_catalog_source,
}
}
Expand Down
1 change: 1 addition & 0 deletions optd-cost-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use optd_persistent::cost_model::interface::{Stat, StatType};
pub mod common;
pub mod cost;
pub mod cost_model;
pub mod storage;

pub enum StatValue {
Int(i64),
Expand Down
14 changes: 14 additions & 0 deletions optd-cost-model/src/storage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use std::sync::Arc;

use optd_persistent::CostModelStorageLayer;

pub struct CostModelStorageManager<CMSL: CostModelStorageLayer> {
pub backend_manager: Arc<CMSL>,
// TODO: in-memory cache
}

impl<CMSL: CostModelStorageLayer> CostModelStorageManager<CMSL> {
pub fn new(backend_manager: Arc<CMSL>) -> Self {
Self { backend_manager }
}
}

0 comments on commit b7034ae

Please sign in to comment.