MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / fetch_cursor

Method fetch_cursor

nodedb/src/control/server/pgwire/session/cursor.rs:34–60  ·  view source on GitHub ↗

Fetch N rows forward from a cursor. Returns (rows, exhausted).

(
        &self,
        addr: &SocketAddr,
        name: &str,
        count: usize,
    )

Source from the content-addressed store, hash-verified

32
33 /// Fetch N rows forward from a cursor. Returns (rows, exhausted).
34 pub fn fetch_cursor(
35 &self,
36 addr: &SocketAddr,
37 name: &str,
38 count: usize,
39 ) -> crate::Result<(Vec<String>, bool)> {
40 self.write_session(addr, |session| {
41 let cursor = session
42 .cursors
43 .get_mut(name)
44 .ok_or_else(|| crate::Error::BadRequest {
45 detail: format!("cursor \"{name}\" does not exist"),
46 })?;
47
48 let start = cursor.position;
49 let end = (start + count).min(cursor.rows.len());
50 let rows: Vec<String> = cursor.rows[start..end].to_vec();
51 cursor.position = end;
52 let exhausted = end >= cursor.rows.len();
53 Ok((rows, exhausted))
54 })
55 .unwrap_or_else(|| {
56 Err(crate::Error::BadRequest {
57 detail: "no active session".to_string(),
58 })
59 })
60 }
61
62 /// Fetch all remaining rows from a cursor.
63 pub fn fetch_cursor_all(&self, addr: &SocketAddr, name: &str) -> crate::Result<Vec<String>> {

Callers 1

handle_fetchMethod · 0.80

Calls 5

write_sessionMethod · 0.80
to_stringMethod · 0.80
get_mutMethod · 0.45
lenMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected