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

Method children_rev

src/transform/src/analysis.rs:220–245  ·  view source on GitHub ↗

Subviews over `self` corresponding to the children of the expression, in reverse order. These views should disjointly cover the same interval as `self`, except for the last element which corresponds to the expression itself. The number of produced items should exactly match the number of children, which need not be provided as an argument. This relies on the well-formedness of the view, which sh

(&self)

Source from the content-addressed store, hash-verified

218 /// be provided as an argument. This relies on the well-formedness of the view, which should
219 /// exhaust itself just as it enumerates its last (the first) child view.
220 pub fn children_rev(&self) -> impl Iterator<Item = DerivedView<'a>> + 'a {
221 // This logic is copy/paste from `Derived::children_of_rev` but it was annoying to layer
222 // it over the output of that function, and perhaps clearer to rewrite in any case.
223
224 // Discard the last element (the size of the expression's subtree).
225 // Repeatedly read out the last element, then peel off that many elements.
226 // Each extracted slice corresponds to a child of the current expression.
227 // We should end cleanly with an empty slice, otherwise there is an issue.
228 let sizes = self.results::<SubtreeSize>();
229 let sizes = &sizes[..sizes.len() - 1];
230
231 let offset = self.lower;
232 let derived = self.derived;
233 (0..).scan(sizes, move |sizes, _| {
234 if let Some(size) = sizes.last() {
235 *sizes = &sizes[..sizes.len() - size];
236 Some(Self {
237 derived,
238 lower: offset + sizes.len(),
239 upper: offset + sizes.len() + size,
240 })
241 } else {
242 None
243 }
244 })
245 }
246
247 /// A convenience method for the view over the expressions last child.
248 ///

Callers 9

applyMethod · 0.80
actionMethod · 0.80
last_childMethod · 0.80
refresh_typesFunction · 0.80
applyMethod · 0.80
transformMethod · 0.80

Calls 3

lastMethod · 0.80
lenMethod · 0.45
scanMethod · 0.45

Tested by

no test coverage detected