Estimate current RAM usage for vector data.
(&self)
| 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 { |
no test coverage detected