pub struct LazyFlatVectorData {
pub dim: usize,
pub num_vectors: usize,
pub doc_ids: Vec<(u32, u16)>,
/* private fields */
}Expand description
Lazy flat vector data — doc_ids in memory, vectors accessed via range reads.
Only the doc_id index (~6 bytes/vector) is loaded into memory. Vector data (~dim×4 bytes/vector) stays on disk and is accessed via mmap-backed range reads on demand. For 768-dim vectors this is ~3KB per vector that stays lazy vs 6 bytes loaded.
Used for:
- Reranking (read individual vectors by doc_id)
- Merge streaming (bulk-read vector bytes in chunks)
Fields§
§dim: usizeVector dimension
num_vectors: usizeTotal number of vectors
doc_ids: Vec<(u32, u16)>In-memory doc_id index: (doc_id, ordinal) per vector
Implementations§
Source§impl LazyFlatVectorData
impl LazyFlatVectorData
Sourcepub async fn open(handle: LazyFileSlice) -> Result<Self>
pub async fn open(handle: LazyFileSlice) -> Result<Self>
Open from a lazy file slice pointing to the flat binary data region.
Reads header (12 bytes) + doc_ids (~6 bytes/vector) into memory. Vector data stays lazy on disk.
Sourcepub async fn read_vector_into(&self, idx: usize, out: &mut [f32]) -> Result<()>
pub async fn read_vector_into(&self, idx: usize, out: &mut [f32]) -> Result<()>
Read a single vector by index into a caller-provided slice (zero allocation).
out must have length >= self.dim. Returns Ok(()) on success.
Sourcepub async fn get_vector(&self, idx: usize) -> Result<Vec<f32>>
pub async fn get_vector(&self, idx: usize) -> Result<Vec<f32>>
Read a single vector by index (allocates a new Vec
Sourcepub async fn read_all_vector_bytes(&self) -> Result<OwnedBytes>
pub async fn read_all_vector_bytes(&self) -> Result<OwnedBytes>
Read all raw vector bytes at once (for bulk streaming in merger).
Returns the contiguous f32 data as owned bytes. Caller writes it directly to the output writer — no f32 parsing needed.
Sourcepub fn get_doc_id(&self, idx: usize) -> (u32, u16)
pub fn get_doc_id(&self, idx: usize) -> (u32, u16)
Get doc_id and ordinal at index (from in-memory index).
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Estimated memory usage (only doc_ids are in memory).
Trait Implementations§
Source§impl Clone for LazyFlatVectorData
impl Clone for LazyFlatVectorData
Source§fn clone(&self) -> LazyFlatVectorData
fn clone(&self) -> LazyFlatVectorData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LazyFlatVectorData
impl !RefUnwindSafe for LazyFlatVectorData
impl Send for LazyFlatVectorData
impl Sync for LazyFlatVectorData
impl Unpin for LazyFlatVectorData
impl !UnwindSafe for LazyFlatVectorData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.