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

Method export_vectors

nodedb-vector/src/hnsw/graph/index.rs:325–336  ·  view source on GitHub ↗

Export all vectors as F32 for snapshot transfer. For F32 indexes this is a clone. For F16/BF16 indexes each vector is decoded to F32 on the fly.

(&self)

Source from the content-addressed store, hash-verified

323 /// For F32 indexes this is a clone. For F16/BF16 indexes each vector is
324 /// decoded to F32 on the fly.
325 pub fn export_vectors(&self) -> Vec<Vec<f32>> {
326 self.nodes
327 .iter()
328 .map(|n| match &n.storage {
329 NodeStorage::F32(v) => v.clone(),
330 NodeStorage::Bytes { dtype, bytes } => {
331 crate::dtype::cast_to_f32(bytes, *dtype, self.dim)
332 .expect("export_vectors: byte-length invariant violated")
333 }
334 })
335 .collect()
336 }
337
338 /// Export all neighbor lists for snapshot transfer.
339 pub fn export_neighbors(&self) -> Vec<Vec<Vec<u32>>> {

Callers 3

export_snapshotMethod · 0.80
checkpoint_to_bytesMethod · 0.80

Calls 5

cast_to_f32Function · 0.85
collectMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45
expectMethod · 0.45

Tested by

no test coverage detected