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

Method populate_expression

src/transform/src/cse/anf.rs:320–333  ·  view source on GitHub ↗

Populates `expression` with necessary `Let` bindings. This population may result in substantially more `Let` bindings that one might expect. It is very appropriate to run the `NormalizeLets` transformation afterwards to remove `Let` bindings that it deems unhelpful.

(self, expression: &mut MirRelationExpr)

Source from the content-addressed store, hash-verified

318 /// might expect. It is very appropriate to run the `NormalizeLets` transformation
319 /// afterwards to remove `Let` bindings that it deems unhelpful.
320 fn populate_expression(self, expression: &mut MirRelationExpr) {
321 // Convert the bindings in to a sequence, by the local identifier.
322 let mut bindings = self.bindings.into_iter().collect::<Vec<_>>();
323 bindings.sort_by_key(|(_, i)| *i);
324
325 for (value, index) in bindings.into_iter().rev() {
326 let new_expression = MirRelationExpr::Let {
327 id: LocalId::new(index),
328 value: Box::new(value),
329 body: Box::new(expression.take_dangerous()),
330 };
331 *expression = new_expression;
332 }
333 }
334}

Callers 2

insert_expressionMethod · 0.80

Calls 3

sort_by_keyMethod · 0.80
take_dangerousMethod · 0.80
into_iterMethod · 0.45

Tested by

no test coverage detected