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

Function execute_offset_statement

crates/gitql-engine/src/engine_executor.rs:297–328  ·  view source on GitHub ↗
(
    env: &mut Environment,
    statement: &OffsetStatement,
    gitql_object: &mut GitQLObject,
)

Source from the content-addressed store, hash-verified

295}
296
297fn execute_offset_statement(
298 env: &mut Environment,
299 statement: &OffsetStatement,
300 gitql_object: &mut GitQLObject,
301) -> Result<(), String> {
302 if gitql_object.is_empty() {
303 return Ok(());
304 }
305
306 if gitql_object.len() > 1 {
307 gitql_object.flat()
308 }
309
310 let main_group: &mut Group = &mut gitql_object.groups[0];
311 let start = &evaluate_expression(
312 env,
313 &statement.start,
314 &gitql_object.titles,
315 &main_group.rows[0].values,
316 )?;
317
318 // If start evaluates to NULL, it is treated the same as OFFSET 0
319 if start.is_null() {
320 return Ok(());
321 }
322
323 let offset = start.as_int().unwrap() as usize;
324 let main_group: &mut Group = &mut gitql_object.groups[0];
325 main_group.rows.drain(0..cmp::min(offset, main_group.len()));
326
327 Ok(())
328}
329
330fn execute_aggregation_functions_statement(
331 env: &mut Environment,

Callers 1

execute_statementFunction · 0.85

Calls 6

evaluate_expressionFunction · 0.85
flatMethod · 0.80
as_intMethod · 0.80
is_emptyMethod · 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…