Skip to content

Commit

Permalink
refine mock interface
Browse files Browse the repository at this point in the history
  • Loading branch information
xx01cyx committed Nov 18, 2024
1 parent 5197090 commit 68b2885
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
40 changes: 4 additions & 36 deletions optd-cost-model/src/cost/agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ mod tests {

use crate::{
common::{
predicates::constant_pred::ConstantType, properties::Attribute, types::TableId,
predicates::constant_pred::ConstantType,
properties::Attribute,
types::{GroupId, TableId},
values::Value,
},
cost_model::tests::{
Expand All @@ -82,21 +84,6 @@ mod tests {
#[tokio::test]
async fn test_agg_no_stats() {
let table_id = TableId(0);
// let attr_infos = HashMap::from([(
// table_id,
// vec![
// Attribute {
// name: String::from("attr1"),
// typ: ConstantType::Int32,
// nullable: false,
// },
// Attribute {
// name: String::from("attr2"),
// typ: ConstantType::Int64,
// nullable: false,
// },
// ],
// )]);
let cost_model = create_mock_cost_model(vec![table_id], vec![], vec![None]);

// Group by empty list should return 1.
Expand Down Expand Up @@ -124,29 +111,10 @@ mod tests {
#[tokio::test]
async fn test_agg_with_stats() {
let table_id = TableId(0);
let group_id = GroupId(0);
let attr1_base_idx = 0;
let attr2_base_idx = 1;
let attr3_base_idx = 2;
// let attr_infos = HashMap::from([(
// table_id,
// vec![
// Attribute {
// name: String::from("attr1"),
// typ: ConstantType::Int32,
// nullable: false,
// },
// Attribute {
// name: String::from("attr2"),
// typ: ConstantType::Int64,
// nullable: false,
// },
// Attribute {
// name: String::from("attr3"),
// typ: ConstantType::Int64,
// nullable: false,
// },
// ],
// )]);

let attr1_ndistinct = 12;
let attr2_ndistinct = 645;
Expand Down
11 changes: 10 additions & 1 deletion optd-cost-model/src/cost_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ pub mod tests {
table_id: Vec<TableId>,
per_attribute_stats: Vec<HashMap<u64, TestPerAttributeStats>>,
row_counts: Vec<Option<u64>>,
) -> TestOptCostModelMock {
create_mock_cost_model_with_memo(table_id, per_attribute_stats, row_counts, HashMap::new())
}

pub fn create_mock_cost_model_with_memo(
table_id: Vec<TableId>,
per_attribute_stats: Vec<HashMap<u64, TestPerAttributeStats>>,
row_counts: Vec<Option<u64>>,
memo: HashMap<GroupId, MemoGroupInfo>,
) -> TestOptCostModelMock {
let storage_manager = CostModelStorageMockManagerImpl::new(
table_id
Expand All @@ -196,7 +205,7 @@ pub mod tests {
CostModelImpl::new(
storage_manager,
CatalogSource::Mock,
Arc::new(MockMemoExtImpl::default()),
Arc::new(MockMemoExtImpl::from(memo)),
)
}

Expand Down

0 comments on commit 68b2885

Please sign in to comment.