Trait mz_adapter::optimize::Optimize
source · 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.
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
type To = OptimizedMirRelationExpr
source§impl Optimize<OptimizedMirRelationExpr> for mz_adapter::optimize::materialized_view::Optimizer
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
.