pub trait PhysicalOptimizerContext: Send + Sync {
// Required method
fn config_options(&self) -> &ConfigOptions;
// Provided methods
fn statistics_registry(&self) -> Option<&StatisticsRegistry> { ... }
fn statistics_context(&self) -> Option<&StatisticsContext> { ... }
fn compute_statistics(
&self,
plan: &Arc<dyn ExecutionPlan>,
args: &StatisticsArgs,
) -> Result<Arc<Statistics>> { ... }
}Expand description
Context available to physical optimizer rules.
This trait provides access to configuration options and an optional statistics registry for enhanced statistics lookup.
Required Methods§
Sourcefn config_options(&self) -> &ConfigOptions
fn config_options(&self) -> &ConfigOptions
Returns the configuration options.
Provided Methods§
Sourcefn statistics_registry(&self) -> Option<&StatisticsRegistry>
fn statistics_registry(&self) -> Option<&StatisticsRegistry>
Returns the statistics registry for enhanced statistics lookup.
Returns None if no registry is configured, in which case rules
should fall back to using ExecutionPlan::partition_statistics.
Sourcefn statistics_context(&self) -> Option<&StatisticsContext>
fn statistics_context(&self) -> Option<&StatisticsContext>
Returns a StatisticsContext shared by every rule of one optimizer
run, so statistics computed by one rule are reused by later rules.
The context must be built from Self::statistics_registry. Its cache
entries hold the plan nodes they were computed for, so it is safe to
share across plan rewrites (see StatisticsContext).
Returns None if no shared context is available, in which case rules
create their own context.
Sourcefn compute_statistics(
&self,
plan: &Arc<dyn ExecutionPlan>,
args: &StatisticsArgs,
) -> Result<Arc<Statistics>>
fn compute_statistics( &self, plan: &Arc<dyn ExecutionPlan>, args: &StatisticsArgs, ) -> Result<Arc<Statistics>>
Computes the statistics of plan with Self::statistics_context,
or, if it is None, with a new context built from
Self::statistics_registry.
Rules that compute statistics should use this, so they reuse the statistics computed by earlier rules and consult the same statistics providers as the built-in rules.
§Example
let plan: Arc<dyn ExecutionPlan> = Arc::new(EmptyExec::new(Arc::new(Schema::empty())));
let statistics = context.compute_statistics(&plan, &StatisticsArgs::new())?;Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".