pub struct VectorIndexTable {
pub index_id: u64,
pub name: String,
pub table_name: String,
pub column_name: String,
pub dimensions: u32,
pub hnsw: HnswIndex,
/* private fields */
}Expand description
A persisted vector index that wraps HnswIndex with BufferManager-backed storage.
§Persistence
save()serializes the in-memory HNSW index to disk pagesload()reads disk pages back into memoryflush()writes dirty pages back to the BufferManager
Fields§
§index_id: u64§name: String§table_name: String§column_name: String§dimensions: u32§hnsw: HnswIndexImplementations§
Source§impl VectorIndexTable
impl VectorIndexTable
Sourcepub fn new(
index_id: u64,
name: String,
table_name: String,
column_name: String,
metric: DistanceMetric,
dimensions: u32,
) -> Self
pub fn new( index_id: u64, name: String, table_name: String, column_name: String, metric: DistanceMetric, dimensions: u32, ) -> Self
Create a new vector index table with the given parameters.
Sourcepub fn hnsw_mut(&mut self) -> &mut HnswIndex
pub fn hnsw_mut(&mut self) -> &mut HnswIndex
Get a mutable reference to the underlying HNSW index.
Sourcepub fn metric(&self) -> DistanceMetric
pub fn metric(&self) -> DistanceMetric
Get the distance metric.
Sourcepub fn save(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
pub fn save(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
Save the in-memory HNSW index to BufferManager-backed pages.
Writes the header page (page 0) and all data pages. Every vector is stored whole on a single page; a vector that does not fit in one page is an error rather than a silent drop (P52.17).
Sourcepub fn load(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
pub fn load(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
Load the HNSW index from BufferManager-backed pages.
Reads the header page and exactly num_vectors entries from the data
pages, rebuilding the in-memory index. Zeroed page tails (which the
page padding leaves behind) are ignored instead of being reconstructed
as phantom empty vectors (P52.17). After loading, the index is fully
searchable.
Sourcepub fn flush(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
pub fn flush(&mut self, bm: &mut BufferManager) -> Result<(), StorageError>
Flush dirty pages to disk via the BufferManager.
Sourcepub fn register_file(&self, bm: &mut BufferManager, db_path: &Path)
pub fn register_file(&self, bm: &mut BufferManager, db_path: &Path)
Register the vector index file with the BufferManager.
Trait Implementations§
Source§impl Clone for VectorIndexTable
impl Clone for VectorIndexTable
Source§fn clone(&self) -> VectorIndexTable
fn clone(&self) -> VectorIndexTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for VectorIndexTable
impl RefUnwindSafe for VectorIndexTable
impl Send for VectorIndexTable
impl Sync for VectorIndexTable
impl Unpin for VectorIndexTable
impl UnsafeUnpin for VectorIndexTable
impl UnwindSafe for VectorIndexTable
Blanket Implementations§
impl<T> Allocation for T
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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 more