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

Function vector_offset

nodedb-vector/src/vamana/storage.rs:120–122  ·  view source on GitHub ↗

Return the byte offset of the full-precision vector for node `idx`. This is the offset to pass to an io_uring `IORING_OP_READ` or `pread` call to fetch `dim * 4` bytes of FP32 data for the given node. # Example ``` use nodedb_vector::vamana::storage::{VamanaStorageLayout, vector_offset}; let layout = VamanaStorageLayout::new(4, 64, 1.2, 100, 0); let off = vector_offset(&layout, 5); // adjacenc

(layout: &VamanaStorageLayout, idx: u64)

Source from the content-addressed store, hash-verified

118/// assert_eq!(off, 25744);
119/// ```
120pub fn vector_offset(layout: &VamanaStorageLayout, idx: u64) -> u64 {
121 layout.vectors_offset + idx * layout.dim as u64 * 4
122}
123
124#[cfg(test)]
125mod tests {

Callers 2

read_syncMethod · 0.85
prefetch_batchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected