(
env: &mut Environment,
selected_rows: &mut [Row],
object_titles: &[String],
selected_expr_titles: &[String],
selected_expr: &[Box<dyn Expr>],
)
| 169 | |
| 170 | #[inline(always)] |
| 171 | fn execute_expression_selection( |
| 172 | env: &mut Environment, |
| 173 | selected_rows: &mut [Row], |
| 174 | object_titles: &[String], |
| 175 | selected_expr_titles: &[String], |
| 176 | selected_expr: &[Box<dyn Expr>], |
| 177 | ) -> Result<(), String> { |
| 178 | // Cache the index of each expression position to provide fast insertion |
| 179 | let mut titles_index_map: HashMap<String, usize> = HashMap::new(); |
| 180 | for expr_column_title in selected_expr_titles { |
| 181 | let expr_title_index = object_titles |
| 182 | .iter() |
| 183 | .position(|r| r.eq(expr_column_title)) |
| 184 | .unwrap(); |
| 185 | titles_index_map.insert(expr_column_title.to_string(), expr_title_index); |
| 186 | } |
| 187 | |
| 188 | for row in selected_rows.iter_mut() { |
| 189 | for (index, expr) in selected_expr.iter().enumerate() { |
| 190 | let expr_title = &selected_expr_titles[index]; |
| 191 | let value_index = *titles_index_map.get(expr_title).unwrap(); |
| 192 | |
| 193 | if index < row.values.len() && !row.values[value_index].is_null() { |
| 194 | continue; |
| 195 | } |
| 196 | |
| 197 | // Ignore evaluating expression if it symbol, that mean it a reference to aggregated value or function |
| 198 | let value = if expr.kind() == ExprKind::Symbol { |
| 199 | Box::new(NullValue) |
| 200 | } else { |
| 201 | evaluate_expression(env, expr, object_titles, &row.values)? |
| 202 | }; |
| 203 | |
| 204 | if index >= row.values.len() { |
| 205 | row.values.push(value); |
| 206 | } else { |
| 207 | row.values[value_index] = value; |
| 208 | } |
| 209 | } |
| 210 | } |
| 211 | Ok(()) |
| 212 | } |
| 213 | |
| 214 | fn execute_where_statement( |
| 215 | env: &mut Environment, |
no test coverage detected
searching dependent graphs…