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

Method approx_size

nodedb/src/data/snapshot.rs:142–169  ·  view source on GitHub ↗

Approximate size in bytes (for progress tracking).

(&self)

Source from the content-addressed store, hash-verified

140
141 /// Approximate size in bytes (for progress tracking).
142 pub fn approx_size(&self) -> usize {
143 let sparse = self
144 .sparse_documents
145 .iter()
146 .map(|kv| kv.key.len() + kv.value.len())
147 .sum::<usize>()
148 + self
149 .sparse_indexes
150 .iter()
151 .map(|kv| kv.key.len() + kv.value.len())
152 .sum::<usize>();
153 let edges = self
154 .edges
155 .iter()
156 .map(|kv| kv.key.len() + kv.value.len() + 4)
157 .sum::<usize>();
158 let vectors: usize = self
159 .hnsw_indexes
160 .iter()
161 .map(|h| h.checkpoint_bytes.len())
162 .sum();
163 let crdt: usize = self
164 .crdt_snapshots
165 .iter()
166 .map(|c| c.snapshot_bytes.len())
167 .sum();
168 sparse + edges + vectors + crdt
169 }
170}
171
172#[cfg(test)]

Callers

nothing calls this directly

Calls 3

sumMethod · 0.80
iterMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected