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

Method permute_fn

src/expr/src/linear.rs:899–926  ·  view source on GitHub ↗

Update input column references, due to an input projection or permutation. The `shuffle` argument remaps expected column identifiers to new locations, with the expectation that `shuffle` describes all input columns, and so the intermediate results will be able to start at position `shuffle.len()`. The supplied `shuffle` might not list columns that are not "demanded" by the instance, and so we sh

(&mut self, remap: F, new_input_arity: usize)

Source from the content-addressed store, hash-verified

897 /// instance, and so we should ensure that `self` is optimized to not reference
898 /// columns that are not demanded.
899 pub fn permute_fn<F>(&mut self, remap: F, new_input_arity: usize)
900 where
901 F: Fn(usize) -> usize,
902 {
903 let (mut map, mut filter, mut project) = self.as_map_filter_project();
904 let map_len = map.len();
905 let action = |col: &mut usize| {
906 if self.input_arity <= *col && *col < self.input_arity + map_len {
907 *col = new_input_arity + (*col - self.input_arity);
908 } else {
909 *col = remap(*col);
910 }
911 };
912 for expr in map.iter_mut() {
913 expr.visit_columns(action);
914 }
915 for pred in filter.iter_mut() {
916 pred.visit_columns(action);
917 }
918 for proj in project.iter_mut() {
919 action(proj);
920 assert!(*proj < new_input_arity + map.len());
921 }
922 *self = Self::new(new_input_arity)
923 .map(map)
924 .filter(filter)
925 .project(project)
926 }
927}
928
929// Optimization routines.

Callers 13

newMethod · 0.80
arrange_byMethod · 0.80
buildMethod · 0.80
completeMethod · 0.80
extract_commonMethod · 0.80
implement_peek_planMethod · 0.80
implement_arrangementsFunction · 0.80
build_compute_dataflowFunction · 0.80
render_reduceMethod · 0.80
export_sinkMethod · 0.80

Calls 7

as_map_filter_projectMethod · 0.80
actionFunction · 0.50
lenMethod · 0.45
visit_columnsMethod · 0.45
projectMethod · 0.45
filterMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected