MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / apply_limit

Method apply_limit

graphlite/src/exec/executor.rs:8460–8483  ·  view source on GitHub ↗

Apply LIMIT clause to query result

(
        &self,
        mut result: QueryResult,
        limit_clause: &crate::ast::LimitClause,
    )

Source from the content-addressed store, hash-verified

8458
8459 /// Apply LIMIT clause to query result
8460 fn apply_limit(
8461 &self,
8462 mut result: QueryResult,
8463 limit_clause: &crate::ast::LimitClause,
8464 ) -> Result<QueryResult, ExecutionError> {
8465 let offset = limit_clause.offset.unwrap_or(0);
8466 let count = limit_clause.count;
8467
8468 // Apply offset
8469 if offset > 0 {
8470 if offset >= result.rows.len() {
8471 result.rows.clear();
8472 } else {
8473 result.rows.drain(0..offset);
8474 }
8475 }
8476
8477 // Apply limit
8478 if result.rows.len() > count {
8479 result.rows.truncate(count);
8480 }
8481
8482 Ok(result)
8483 }
8484
8485 /// Expand SELECT items, handling wildcard (*) by creating return items for all node properties
8486 fn expand_select_items(

Calls 2

lenMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected