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

Method ram_usage_bytes

nodedb-vector/src/collection/budget.rs:23–38  ·  view source on GitHub ↗

Estimate current RAM usage for vector data.

(&self)

Source from the content-addressed store, hash-verified

21
22 /// Estimate current RAM usage for vector data.
23 pub fn ram_usage_bytes(&self) -> usize {
24 let bytes_per_vector = self.dim * std::mem::size_of::<f32>();
25 let growing = self.growing.len() * bytes_per_vector;
26 let building: usize = self
27 .building
28 .iter()
29 .map(|b| b.flat.len() * bytes_per_vector)
30 .sum();
31 let sealed_ram: usize = self
32 .sealed
33 .iter()
34 .filter(|s| s.tier == StorageTier::L0Ram)
35 .map(|s| s.index.len() * bytes_per_vector)
36 .sum();
37 growing + building + sealed_ram
38 }
39
40 /// Whether the RAM budget is exceeded.
41 pub fn is_budget_exceeded(&self) -> bool {

Callers 1

is_budget_exceededMethod · 0.80

Calls 3

sumMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected