MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / optimize_oneshot

Function optimize_oneshot

src/adapter/src/optimize.rs:226–240  ·  view source on GitHub ↗

Runs the shared one-shot optimization pipeline for a single optimizer. This factors out the (otherwise duplicated) HIR ⇒ local MIR ⇒ resolve ⇒ global LIR sequence that is common to the `SELECT`/`EXPLAIN` and `COPY TO` paths. The `resolve` closure attaches the timestamp/session/stats context to the local plan; it is path-specific only in the concrete plan type it operates on.

(
    optimizer: &mut O,
    raw_expr: HirRelationExpr,
    resolve: impl FnOnce(LocalPlan) -> ResolvedPlan,
)

Source from the content-addressed store, hash-verified

224/// the local plan; it is path-specific only in the concrete plan type it
225/// operates on.
226pub(crate) fn optimize_oneshot<O, LocalPlan, ResolvedPlan, GlobalPlan>(
227 optimizer: &mut O,
228 raw_expr: HirRelationExpr,
229 resolve: impl FnOnce(LocalPlan) -> ResolvedPlan,
230) -> Result<GlobalPlan, OptimizerError>
231where
232 O: Optimize<HirRelationExpr, To = LocalPlan> + Optimize<ResolvedPlan, To = GlobalPlan>,
233{
234 // HIR ⇒ MIR lowering and MIR optimization (local).
235 let local_mir_plan = optimizer.catch_unwind_optimize(raw_expr)?;
236 // Attach resolved context required to continue the pipeline.
237 let resolved_mir_plan = resolve(local_mir_plan);
238 // MIR optimization (global), MIR ⇒ LIR lowering, and LIR optimization (global).
239 optimizer.catch_unwind_optimize(resolved_mir_plan)
240}
241
242// Optimizer configuration
243// -----------------------

Callers 2

optimizeMethod · 0.85

Calls 2

resolveFunction · 0.85
catch_unwind_optimizeMethod · 0.80

Tested by

no test coverage detected