Skip to content

Commit 22656e6

Browse files
committed
make get_attributes_comb_statistics return Option
1 parent cda219c commit 22656e6

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

optd-cost-model/src/cost/filter.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,10 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
269269
) -> CostModelResult<f64> {
270270
// TODO: The attribute could be a derived attribute
271271
let ret_sel = {
272-
let attribute_stats = self.get_attribute_comb_stats(table_id, &[attr_base_index])?;
272+
// TODO: Handle the case where `attribute_stats` is None.
273+
let attribute_stats = self
274+
.get_attribute_comb_stats(table_id, &[attr_base_index])?
275+
.unwrap();
273276
let eq_freq = if let Some(freq) = attribute_stats.mcvs.freq(&vec![Some(value.clone())])
274277
{
275278
freq
@@ -355,7 +358,10 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
355358
end: Bound<&Value>,
356359
) -> CostModelResult<f64> {
357360
// TODO: Consider attribute is a derived attribute
358-
let attribute_stats = self.get_attribute_comb_stats(table_id, &[attr_base_index])?;
361+
// TODO: Handle the case where `attribute_stats` is None.
362+
let attribute_stats = self
363+
.get_attribute_comb_stats(table_id, &[attr_base_index])?
364+
.unwrap();
359365
let left_quantile = match start {
360366
Bound::Unbounded => 0.0,
361367
Bound::Included(value) => self.get_attribute_lt_value_freq(
@@ -439,7 +445,10 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
439445
.min(1.0);
440446

441447
// Compute the selectivity in MCVs.
442-
let attribute_stats = self.get_attribute_comb_stats(table_id, &[attr_ref_idx])?;
448+
// TODO: Handle the case where `attribute_stats` is None.
449+
let attribute_stats = self
450+
.get_attribute_comb_stats(table_id, &[attr_ref_idx])?
451+
.unwrap();
443452
let (mcv_freq, null_frac) = {
444453
let pred = Box::new(move |val: &AttributeCombValue| {
445454
let string = StringArray::from(vec![val[0].as_ref().unwrap().as_str().as_ref()]);

optd-cost-model/src/cost_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<S: CostModelStorageLayer> CostModelImpl<S> {
101101
&self,
102102
table_id: TableId,
103103
attr_comb: &[usize],
104-
) -> CostModelResult<AttributeCombValueStats> {
104+
) -> CostModelResult<Option<AttributeCombValueStats>> {
105105
self.storage_manager
106106
.get_attributes_comb_statistics(table_id, attr_comb)
107107
}

optd-cost-model/src/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<S: CostModelStorageLayer> CostModelStorageManager<S> {
5757
&self,
5858
table_id: TableId,
5959
attr_comb: &[usize],
60-
) -> CostModelResult<AttributeCombValueStats> {
60+
) -> CostModelResult<Option<AttributeCombValueStats>> {
6161
todo!()
6262
}
6363
}

0 commit comments

Comments
 (0)