MCPcopy Create free account
hub / github.com/AmrDeveloper/GQL / execute_expression_selection

Function execute_expression_selection

crates/gitql-engine/src/engine_executor.rs:171–212  ·  view source on GitHub ↗
(
    env: &mut Environment,
    selected_rows: &mut [Row],
    object_titles: &[String],
    selected_expr_titles: &[String],
    selected_expr: &[Box<dyn Expr>],
)

Source from the content-addressed store, hash-verified

169
170#[inline(always)]
171fn 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
214fn execute_where_statement(
215 env: &mut Environment,

Callers 1

execute_select_statementFunction · 0.85

Calls 5

evaluate_expressionFunction · 0.85
kindMethod · 0.80
eqMethod · 0.45
lenMethod · 0.45
is_nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…