pub trait Optimize<From>: Sendwhere
From: Send,{
type To: Send;
// Required method
fn optimize(&mut self, plan: From) -> Result<Self::To, OptimizerError>;
// Provided methods
fn catch_unwind_optimize(
&mut self,
plan: From,
) -> Result<Self::To, OptimizerError> { ... }
fn must_optimize(&mut self, expr: From) -> Self::To { ... }
}Expand description
A trait that represents an optimization stage.
The trait is implemented by structs that encapsulate the context needed to
run an end-to-end optimization pipeline for a specific statement type
(Index, View, MaterializedView, Subscribe, Select).
Each implementation represents a concrete optimization stage for a fixed
statement type that consumes an input of type From and produces output of
type Self::To.
The generic lifetime 'ctx models the lifetime of the optimizer context and
can be passed to the optimizer struct and the Self::To types.
The 's: 'ctx bound in the optimize method call ensures that an optimizer
instance can run an optimization stage that produces a Self::To with
&'ctx references.
Required Associated Types§
Required Methods§
Sourcefn optimize(&mut self, plan: From) -> Result<Self::To, OptimizerError>
fn optimize(&mut self, plan: From) -> Result<Self::To, OptimizerError>
Execute the optimization stage, transforming the input plan of type
From to an output plan of type To.
Provided Methods§
Sourcefn catch_unwind_optimize(
&mut self,
plan: From,
) -> Result<Self::To, OptimizerError>
fn catch_unwind_optimize( &mut self, plan: From, ) -> Result<Self::To, OptimizerError>
Like Self::optimize, but additionally ensures that panics occurring
in the Self::optimize call are caught and demoted to an
OptimizerError::Internal error.
Additionally, if the result of the optimization is an error (not a panic) that indicates we should panic, then panic.
Sourcefn must_optimize(&mut self, expr: From) -> Self::To
fn must_optimize(&mut self, expr: From) -> Self::To
Execute the optimization stage and panic if an error occurs.
See Optimize::optimize.
Implementors§
Source§impl Optimize<SubscribeFrom> for mz_adapter::optimize::subscribe::Optimizer
impl Optimize<SubscribeFrom> for mz_adapter::optimize::subscribe::Optimizer
type To = GlobalMirPlan<Unresolved>
Source§impl Optimize<HirRelationExpr> for mz_adapter::optimize::copy_to::Optimizer
impl Optimize<HirRelationExpr> for mz_adapter::optimize::copy_to::Optimizer
type To = LocalMirPlan
Source§impl Optimize<HirRelationExpr> for mz_adapter::optimize::materialized_view::Optimizer
impl Optimize<HirRelationExpr> for mz_adapter::optimize::materialized_view::Optimizer
type To = LocalMirPlan
Source§impl Optimize<HirRelationExpr> for mz_adapter::optimize::peek::Optimizer
impl Optimize<HirRelationExpr> for mz_adapter::optimize::peek::Optimizer
type To = LocalMirPlan
Source§impl Optimize<HirRelationExpr> for mz_adapter::optimize::view::Optimizer<'_>
impl Optimize<HirRelationExpr> for mz_adapter::optimize::view::Optimizer<'_>
Source§impl Optimize<OptimizedMirRelationExpr> for mz_adapter::optimize::materialized_view::Optimizer
This is needed only because the pipeline in the bootstrap code starts from an
OptimizedMirRelationExpr attached to a mz_catalog::memory::objects::CatalogItem.
impl Optimize<OptimizedMirRelationExpr> for mz_adapter::optimize::materialized_view::Optimizer
This is needed only because the pipeline in the bootstrap code starts from an
OptimizedMirRelationExpr attached to a mz_catalog::memory::objects::CatalogItem.