If the `PropagationResult` indicates success, this function calculates the selectivity value by comparing the initial and final column boundaries. Following this, it constructs and returns a new `AnalysisContext` with the updated parameters.
(
graph: &ExprIntervalGraph,
mut target_boundaries: Vec<ExprBoundaries>,
target_expr_and_indices: &[(Arc<dyn PhysicalExpr>, usize)],
)
| 235 | /// Following this, it constructs and returns a new `AnalysisContext` with the |
| 236 | /// updated parameters. |
| 237 | fn shrink_boundaries( |
| 238 | graph: &ExprIntervalGraph, |
| 239 | mut target_boundaries: Vec<ExprBoundaries>, |
| 240 | target_expr_and_indices: &[(Arc<dyn PhysicalExpr>, usize)], |
| 241 | ) -> Result<AnalysisContext> { |
| 242 | let initial_boundaries = target_boundaries.clone(); |
| 243 | target_expr_and_indices.iter().for_each(|(expr, i)| { |
| 244 | if let Some(column) = expr.downcast_ref::<Column>() |
| 245 | && let Some(bound) = target_boundaries |
| 246 | .iter_mut() |
| 247 | .find(|bound| bound.column.eq(column)) |
| 248 | { |
| 249 | bound.interval = Some(graph.get_interval(*i)); |
| 250 | }; |
| 251 | }); |
| 252 | |
| 253 | let selectivity = calculate_selectivity(&target_boundaries, &initial_boundaries)?; |
| 254 | |
| 255 | assert_or_internal_err!( |
| 256 | (0.0..=1.0).contains(&selectivity), |
| 257 | "Selectivity is out of limit: {selectivity}", |
| 258 | ); |
| 259 | |
| 260 | Ok(AnalysisContext::new(target_boundaries).with_selectivity(selectivity)) |
| 261 | } |
| 262 | |
| 263 | /// Returns `Some(1.0 / distinct_count)` when the filter demonstrably collapsed |
| 264 | /// a non-singleton interval down to a single point, i.e. an equality predicate |
no test coverage detected
searching dependent graphs…