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

Function parse_count_from_payload

nodedb/src/engine/bitemporal/enforcement.rs:187–209  ·  view source on GitHub ↗

Decode the purge count from a response payload. EdgeStore / Columnar → 8 bytes LE u64 (count). DocumentStrict → 16 bytes: docs LE u64 ++ index-entries LE u64; we sum them for the audit-record count so operators see total rows reclaimed across the two versioned tables.

(engine: BitemporalEngineKind, payload: &[u8])

Source from the content-addressed store, hash-verified

185/// sum them for the audit-record count so operators see total rows
186/// reclaimed across the two versioned tables.
187fn parse_count_from_payload(engine: BitemporalEngineKind, payload: &[u8]) -> u64 {
188 match engine {
189 BitemporalEngineKind::EdgeStore
190 | BitemporalEngineKind::Columnar
191 | BitemporalEngineKind::Crdt
192 | BitemporalEngineKind::Array => {
193 if payload.len() >= 8 {
194 u64::from_le_bytes(payload[..8].try_into().unwrap_or([0; 8]))
195 } else {
196 0
197 }
198 }
199 BitemporalEngineKind::DocumentStrict => {
200 if payload.len() >= 16 {
201 let docs = u64::from_le_bytes(payload[..8].try_into().unwrap_or([0; 8]));
202 let idx = u64::from_le_bytes(payload[8..16].try_into().unwrap_or([0; 8]));
203 docs.saturating_add(idx)
204 } else {
205 0
206 }
207 }
208 }
209}
210
211#[cfg(test)]
212mod tests {

Callers 1

run_oneFunction · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected