pub struct MmapVectorFile {
pub mmap: MmapMut,
pub header: VecFileHeader,
pub path: PathBuf,
}Expand description
A memory-mapped file containing fixed-size raw f32 vectors.
Fields§
§mmap: MmapMutWritable mmap covering the full file.
header: VecFileHeaderDecoded file header.
path: PathBufFile path on disk.
Implementations§
Source§impl MmapVectorFile
impl MmapVectorFile
Sourcepub fn create(
path: &Path,
dimensions: usize,
max_elements: usize,
) -> VectorResult<Self>
pub fn create( path: &Path, dimensions: usize, max_elements: usize, ) -> VectorResult<Self>
Create a new vector file with capacity for max_elements vectors.
Sourcepub fn open(path: &Path) -> VectorResult<Self>
pub fn open(path: &Path) -> VectorResult<Self>
Open an existing vector file and validate its header.
Sourcepub fn write_vector(
&mut self,
internal_id: usize,
vector: &[f32],
) -> VectorResult<()>
pub fn write_vector( &mut self, internal_id: usize, vector: &[f32], ) -> VectorResult<()>
Write a vector to a fixed slot, updating the element count if needed.
Sourcepub fn read_vector(&self, internal_id: usize) -> VectorResult<Vec<f32>>
pub fn read_vector(&self, internal_id: usize) -> VectorResult<Vec<f32>>
Read a vector from a fixed slot.
Sourcepub fn delete_vector(&mut self, internal_id: usize) -> VectorResult<()>
pub fn delete_vector(&mut self, internal_id: usize) -> VectorResult<()>
Zero out a vector slot without changing the file capacity.
Sourcepub fn flush(&self) -> VectorResult<()>
pub fn flush(&self) -> VectorResult<()>
Flush pending changes to disk.
Sourcepub fn element_count(&self) -> usize
pub fn element_count(&self) -> usize
Return the number of written slots tracked in the header.
Sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Return the dimensionality of vectors stored in the file.
Sourcepub fn file_size_bytes(&self) -> u64
pub fn file_size_bytes(&self) -> u64
Return the total file size in bytes.
Auto Trait Implementations§
impl Freeze for MmapVectorFile
impl RefUnwindSafe for MmapVectorFile
impl Send for MmapVectorFile
impl Sync for MmapVectorFile
impl Unpin for MmapVectorFile
impl UnsafeUnpin for MmapVectorFile
impl UnwindSafe for MmapVectorFile
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
Mutably borrows from an owned value. Read more
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> 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>
Converts
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>
Converts
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request