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

Method scan_with_surrogate

nodedb/src/engine/kv/scan.rs:59–85  ·  view source on GitHub ↗

Like [`scan`], but surfaces each row's surrogate alongside its key/value so a caller can filter by clone snapshot-isolation ceiling (drop rows bound after the AS-OF point).

(
        &self,
        cursor_idx: usize,
        count: usize,
        now_ms: u64,
        match_pattern: Option<&str>,
    )

Source from the content-addressed store, hash-verified

57 /// key/value so a caller can filter by clone snapshot-isolation
58 /// ceiling (drop rows bound after the AS-OF point).
59 pub fn scan_with_surrogate(
60 &self,
61 cursor_idx: usize,
62 count: usize,
63 now_ms: u64,
64 match_pattern: Option<&str>,
65 ) -> ScanBatchWithSurrogate<'_> {
66 let mut results = Vec::with_capacity(count);
67 let total_slots = self.capacity() + self.rehash_source_len();
68
69 let mut idx = cursor_idx;
70 while results.len() < count && idx < total_slots {
71 let entry = self.slot_at(idx);
72
73 if let Some(e) = entry
74 && !e.is_expired(now_ms)
75 && matches_pattern(&e.key, match_pattern)
76 {
77 let value = self.read_value(e);
78 results.push((e.key.as_slice(), value, e.surrogate));
79 }
80 idx += 1;
81 }
82
83 let next_cursor = if idx >= total_slots { 0 } else { idx };
84 (results, next_cursor)
85 }
86
87 /// Access a slot by unified index (primary first, then rehash source).
88 fn slot_at(&self, idx: usize) -> Option<&KvEntry> {

Callers 2

scanMethod · 0.80
scanMethod · 0.80

Calls 9

matches_patternFunction · 0.85
rehash_source_lenMethod · 0.80
slot_atMethod · 0.80
read_valueMethod · 0.80
capacityMethod · 0.45
lenMethod · 0.45
is_expiredMethod · 0.45
pushMethod · 0.45
as_sliceMethod · 0.45

Tested by

no test coverage detected