pub struct AdaptiveContext { /* private fields */ }Expand description
Context for adaptive query execution.
Holds both estimated and actual cardinalities, and provides methods to determine when re-optimization should occur.
Implementations§
Source§impl AdaptiveContext
impl AdaptiveContext
Sourcepub fn with_thresholds(threshold: f64, min_rows: u64) -> Self
pub fn with_thresholds(threshold: f64, min_rows: u64) -> Self
Creates a context with custom thresholds.
Sourcepub fn set_estimate(&mut self, operator_id: &str, estimate: f64)
pub fn set_estimate(&mut self, operator_id: &str, estimate: f64)
Sets the estimated cardinality for an operator.
Sourcepub fn record_actual(&mut self, operator_id: &str, actual: u64)
pub fn record_actual(&mut self, operator_id: &str, actual: u64)
Records the actual cardinality for an operator.
Sourcepub fn apply_feedback(&mut self, feedback: &CardinalityFeedback)
pub fn apply_feedback(&mut self, feedback: &CardinalityFeedback)
Applies feedback from a CardinalityFeedback collector.
Sourcepub fn has_significant_deviation(&self) -> bool
pub fn has_significant_deviation(&self) -> bool
Checks if any checkpoint shows significant deviation.
Sourcepub fn should_reoptimize(&mut self) -> bool
pub fn should_reoptimize(&mut self) -> bool
Determines if re-optimization should be triggered.
Returns true if:
- There’s significant deviation from estimates
- We’ve processed enough rows to make a meaningful decision
- Re-optimization hasn’t already been triggered
Sourcepub fn trigger_operator(&self) -> Option<&str>
pub fn trigger_operator(&self) -> Option<&str>
Returns the operator that triggered re-optimization, if any.
Sourcepub fn get_checkpoint(
&self,
operator_id: &str,
) -> Option<&CardinalityCheckpoint>
pub fn get_checkpoint( &self, operator_id: &str, ) -> Option<&CardinalityCheckpoint>
Gets the checkpoint for an operator.
Sourcepub fn all_checkpoints(&self) -> &HashMap<String, CardinalityCheckpoint>
pub fn all_checkpoints(&self) -> &HashMap<String, CardinalityCheckpoint>
Returns all checkpoints.
Sourcepub fn correction_factor(&self, operator_id: &str) -> f64
pub fn correction_factor(&self, operator_id: &str) -> f64
Calculates a correction factor for a specific operator.
This factor can be used to adjust remaining cardinality estimates.
Sourcepub fn summary(&self) -> AdaptiveSummary
pub fn summary(&self) -> AdaptiveSummary
Returns summary statistics about the adaptive execution.