pub struct VectorCollection { /* private fields */ }Expand description
Scale-aware vector collection
Implementations§
Source§impl VectorCollection
impl VectorCollection
Sourcepub fn open(conn: &Arc<SochConnection>, name: &str) -> Result<Self>
pub fn open(conn: &Arc<SochConnection>, name: &str) -> Result<Self>
Open or create a vector collection
Sourcepub fn create(
conn: &Arc<SochConnection>,
name: &str,
dimension: usize,
) -> Result<Self>
pub fn create( conn: &Arc<SochConnection>, name: &str, dimension: usize, ) -> Result<Self>
Create a new collection with specified dimension
Sourcepub fn train_pq(&mut self) -> Result<()>
pub fn train_pq(&mut self) -> Result<()>
Train the Product Quantizer on existing vectors
Should be called after adding sufficient vectors (at least 1000). Training improves search quality significantly.
Sourcepub fn is_pq_trained(&self) -> bool
pub fn is_pq_trained(&self) -> bool
Check if PQ is trained
Sourcepub fn add(&mut self, ids: &[&str], vectors: &[Vec<f32>]) -> Result<()>
pub fn add(&mut self, ids: &[&str], vectors: &[Vec<f32>]) -> Result<()>
Add vectors (auto-promotes backend if needed)
Sourcepub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
pub fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
Search for nearest neighbors
Sourcepub fn stats(&self) -> VectorStats
pub fn stats(&self) -> VectorStats
Get statistics
Sourcepub fn compression_ratio(&self) -> Option<f32>
pub fn compression_ratio(&self) -> Option<f32>
Get compression ratio if PQ is trained
Sourcepub fn migrate_batch(&mut self) -> Result<usize>
pub fn migrate_batch(&mut self) -> Result<usize>
Migrate a batch of vectors (call periodically during idle time)
Auto Trait Implementations§
impl !Freeze for VectorCollection
impl !RefUnwindSafe for VectorCollection
impl Send for VectorCollection
impl Sync for VectorCollection
impl Unpin for VectorCollection
impl !UnwindSafe for VectorCollection
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 more