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.
Not Send or Sync — owned by a single Data Plane core.
Implementations§
Source§impl MmapVectorSegment
impl MmapVectorSegment
Sourcepub fn create(path: &Path, dim: usize, vectors: &[&[f32]]) -> Result<Self>
pub fn create(path: &Path, dim: usize, vectors: &[&[f32]]) -> Result<Self>
Create a new segment file (surrogates default to 0) and open it.
Sourcepub fn create_with_surrogates(
path: &Path,
dim: usize,
vectors: &[&[f32]],
surrogate_ids: &[u64],
) -> Result<Self>
pub fn create_with_surrogates( path: &Path, dim: usize, vectors: &[&[f32]], surrogate_ids: &[u64], ) -> Result<Self>
Create a new segment file with explicit surrogate IDs and open it.
Sourcepub fn create_with_policy(
path: &Path,
dim: usize,
vectors: &[&[f32]],
policy: VectorSegmentDropPolicy,
) -> Result<Self>
pub fn create_with_policy( path: &Path, dim: usize, vectors: &[&[f32]], policy: VectorSegmentDropPolicy, ) -> Result<Self>
Create a new segment with an explicit drop policy.
Sourcepub fn open_with_policy(
path: &Path,
policy: VectorSegmentDropPolicy,
) -> Result<Self>
pub fn open_with_policy( path: &Path, policy: VectorSegmentDropPolicy, ) -> Result<Self>
Open an existing segment with an explicit drop policy.
Sourcepub fn open_with_governor(
path: &Path,
governor: &Arc<MemoryGovernor>,
) -> Result<Self, VectorError>
pub fn open_with_governor( path: &Path, governor: &Arc<MemoryGovernor>, ) -> Result<Self, VectorError>
Open an existing segment with a memory governor.
Reserves file_size bytes in the EngineId::Vector budget before
mapping the file. Returns VectorError::BudgetExhausted if the
governor rejects the reservation. The reservation is released
automatically when the segment is dropped (RAII via BudgetGuard).
Sourcepub fn open_with_governor_and_policy(
path: &Path,
governor: &Arc<MemoryGovernor>,
policy: VectorSegmentDropPolicy,
) -> Result<Self, VectorError>
pub fn open_with_governor_and_policy( path: &Path, governor: &Arc<MemoryGovernor>, policy: VectorSegmentDropPolicy, ) -> Result<Self, VectorError>
Open an existing segment with a memory governor and explicit drop policy.
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
Auto Trait Implementations§
impl Freeze for MmapVectorSegment
impl RefUnwindSafe for MmapVectorSegment
impl !Send for MmapVectorSegment
impl !Sync 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
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.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.