pub struct MmapVectorSegment { /* private fields */ }Expand description
Memory-mapped vector segment file (v2 NDVS format).
Exposes a &[f32] view of the vector data block and a &[u64] view of
the surrogate ID block — both zero-copy slices into the mmap region.
Typically owned by a single Data Plane core, but safe to share across
threads behind an [Arc]: see the Send/Sync safety note below.
Implementations§
Source§impl MmapVectorSegment
impl MmapVectorSegment
Sourcepub fn create(
dir: &Path,
name: &str,
dim: usize,
vectors: &[&[f32]],
memory: &ScopedMemory,
) -> Result<Self, VectorError>
pub fn create( dir: &Path, name: &str, dim: usize, vectors: &[&[f32]], memory: &ScopedMemory, ) -> Result<Self, VectorError>
Create the segment file name inside dir (surrogates default to 0)
and open it, tracked against memory.
Sourcepub fn create_with_surrogates(
dir: &Path,
name: &str,
dim: usize,
vectors: &[&[f32]],
surrogate_ids: &[u64],
memory: &ScopedMemory,
) -> Result<Self, VectorError>
pub fn create_with_surrogates( dir: &Path, name: &str, dim: usize, vectors: &[&[f32]], surrogate_ids: &[u64], memory: &ScopedMemory, ) -> Result<Self, VectorError>
Create the segment file name inside dir with explicit surrogate IDs
and open it, tracked against memory.
Sourcepub fn create_with_policy(
dir: &Path,
name: &str,
dim: usize,
vectors: &[&[f32]],
policy: VectorSegmentDropPolicy,
memory: &ScopedMemory,
) -> Result<Self, VectorError>
pub fn create_with_policy( dir: &Path, name: &str, dim: usize, vectors: &[&[f32]], policy: VectorSegmentDropPolicy, memory: &ScopedMemory, ) -> Result<Self, VectorError>
Create the segment file name inside dir with an explicit drop
policy, tracked against memory.
Sourcepub fn open(path: &Path, memory: &ScopedMemory) -> Result<Self, VectorError>
pub fn open(path: &Path, memory: &ScopedMemory) -> Result<Self, VectorError>
Open an existing segment file and memory-map it.
Reserves file_size bytes against the bound database, tenant, and
engine budget before mapping the file. Returns
VectorError::BudgetExhausted if the reservation is rejected. The
reservation is released automatically when the segment is dropped
(RAII via ReservationToken).
Sourcepub fn open_with_policy(
path: &Path,
memory: &ScopedMemory,
policy: VectorSegmentDropPolicy,
) -> Result<Self, VectorError>
pub fn open_with_policy( path: &Path, memory: &ScopedMemory, policy: VectorSegmentDropPolicy, ) -> Result<Self, VectorError>
Open an existing segment with an explicit drop policy, tracked
against memory.
Sourcepub fn madvise_state(&self) -> Option<c_int>
pub fn madvise_state(&self) -> Option<c_int>
The madvise hint set on this segment (if any).
Sourcepub fn get_vector(&self, id: u32) -> Option<&[f32]>
pub fn get_vector(&self, id: u32) -> Option<&[f32]>
Get a vector by local index. Returns a slice into the mmap’d region.
Sourcepub fn get_surrogate_id(&self, id: u32) -> Option<u64>
pub fn get_surrogate_id(&self, id: u32) -> Option<u64>
Get the surrogate ID for a local index (0-based row in this segment).
Sourcepub fn all_vectors_flat(&self) -> &[f32]
pub fn all_vectors_flat(&self) -> &[f32]
The full vector data block as a contiguous &[f32] of length D × N.
Suitable for SIMD distance computation over all vectors.
Sourcepub fn all_surrogate_ids(&self) -> &[u64]
pub fn all_surrogate_ids(&self) -> &[u64]
The full surrogate ID block as a contiguous &[u64] of length N.
Parallel to all_vectors_flat: row i in vectors ↔ surrogate_ids[i].
Sourcepub fn prefetch(&self, id: u32)
pub fn prefetch(&self, id: u32)
Prefetch a vector’s page into memory via madvise(MADV_WILLNEED).
Sourcepub fn prefetch_batch(&self, ids: &[u32])
pub fn prefetch_batch(&self, ids: &[u32])
Prefetch a batch of vector IDs.
pub fn dim(&self) -> usize
pub fn count(&self) -> usize
pub fn path(&self) -> &Path
pub fn mmap_bytes(&self) -> usize
pub fn file_size(&self) -> usize
Trait Implementations§
Source§impl Debug for MmapVectorSegment
impl Debug for MmapVectorSegment
Source§impl Drop for MmapVectorSegment
impl Drop for MmapVectorSegment
impl Send for MmapVectorSegment
impl Sync for MmapVectorSegment
Auto Trait Implementations§
impl Freeze for MmapVectorSegment
impl RefUnwindSafe for MmapVectorSegment
impl Unpin for MmapVectorSegment
impl UnsafeUnpin for MmapVectorSegment
impl UnwindSafe for MmapVectorSegment
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
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.