Retain only rows satisfying these predicates. This method introduces predicates as eagerly as they can be evaluated, which may not be desired for predicates that may cause exceptions. If fine manipulation is required, the predicates can be added manually.
(mut self, predicates: I)
| 129 | /// which may not be desired for predicates that may cause exceptions. |
| 130 | /// If fine manipulation is required, the predicates can be added manually. |
| 131 | pub fn filter<I>(mut self, predicates: I) -> Self |
| 132 | where |
| 133 | I: IntoIterator<Item = E>, |
| 134 | { |
| 135 | for mut predicate in predicates { |
| 136 | // Correct column references. |
| 137 | predicate.permute(&self.projection[..]); |
| 138 | |
| 139 | // Validate column references. |
| 140 | assert!( |
| 141 | predicate |
| 142 | .support() |
| 143 | .into_iter() |
| 144 | .all(|c| c < self.input_arity + self.expressions.len()) |
| 145 | ); |
| 146 | |
| 147 | // Insert predicate as eagerly as it can be evaluated: |
| 148 | // just after the largest column in its support is formed. |
| 149 | let max_support = predicate |
| 150 | .support() |
| 151 | .into_iter() |
| 152 | .max() |
| 153 | .map(|c| c + 1) |
| 154 | .unwrap_or(0); |
| 155 | self.predicates.push((max_support, predicate)) |
| 156 | } |
| 157 | // Stable sort predicates by position at which they take effect. |
| 158 | // We put literal errors at the end as a stop-gap to avoid erroring |
| 159 | // before we are able to evaluate any predicates that might prevent it. |
| 160 | self.predicates |
| 161 | .sort_by_key(|(position, predicate)| (E::is_literal_err(predicate), *position)); |
| 162 | self |
| 163 | } |
| 164 | |
| 165 | /// Append the result of evaluating expressions to each row. |
| 166 | pub fn map<I>(mut self, expressions: I) -> Self |