pub trait VectorRef {
// Required method
fn as_slice(&self) -> &[f32];
// Provided methods
fn dimension(&self) -> usize { ... }
fn is_empty(&self) -> bool { ... }
}Expand description
A reference to vector data that may be borrowed or owned.
This trait abstracts over different ways to access vector data:
&[f32]: Direct slice reference (zero-copy from mmap)Cow<[f32]>: Copy-on-write for flexibilityVec<f32>: Owned data when needed
§Example
ⓘ
use velesdb_core::VectorRef;
fn compute_distance<V: VectorRef>(a: &V, b: &V) -> f32 {
let a_slice = a.as_slice();
let b_slice = b.as_slice();
// SIMD distance calculation on slices
crate::simd::cosine_similarity_fast(a_slice, b_slice)
}