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

Method get_vector

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

Returns a `&[f32]` view of the stored vector for node `id`. Returns `Some` only when the index dtype is `F32`. For `F16` or `BF16` indexes this method returns `None` — use [`Self::get_vector_bytes`] instead and decode via [`crate::dtype::cast_to_f32`] if an f32 view is needed. In debug builds, calling this on a non-F32 index triggers a `debug_assert!` to flag misuse early. In release builds the

(&self, id: u32)

Source from the content-addressed store, hash-verified

214 /// `debug_assert!` to flag misuse early. In release builds the
215 /// `debug_assert!` is a no-op and `None` is returned silently.
216 pub fn get_vector(&self, id: u32) -> Option<&[f32]> {
217 debug_assert!(
218 self.params.dtype == VectorStorageDtype::F32,
219 "get_vector: called on non-F32 index (dtype={}); use get_vector_bytes instead",
220 self.params.dtype,
221 );
222 self.nodes
223 .get(id as usize)
224 .and_then(|n| n.storage.as_f32_slice())
225 }
226
227 /// Dtype-agnostic byte view of the stored vector for node `id`.
228 ///

Callers 15

export_snapshotMethod · 0.45
sealMethod · 0.45
build_sq8_for_indexMethod · 0.45
build_pq_for_indexMethod · 0.45
quantized_searchFunction · 0.45
attach_sq8Function · 0.45
brute_force_on_allowedFunction · 0.45
distFunction · 0.45

Calls 2

as_f32_sliceMethod · 0.80
getMethod · 0.45

Tested by 6

search_finds_exact_matchFunction · 0.36
search_recall_at_10Function · 0.36
f32_default_unchangedFunction · 0.36