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)
| 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. |
no test coverage detected