pub struct ScalarQuantizedIndex { /* private fields */ }Expand description
Compact scalar-int8 cosine index.
Stored vectors use one byte per component plus one norm scalar. Search
distances are quantized approximations unless Self::search_rerank is
used with an owned f32 index.
Implementations§
Source§impl ScalarQuantizedIndex
impl ScalarQuantizedIndex
Sourcepub fn build(
config: IndexConfig,
vectors: &[(u64, &[f32])],
) -> Result<Self, SearchError>
pub fn build( config: IndexConfig, vectors: &[(u64, &[f32])], ) -> Result<Self, SearchError>
Validates, normalizes, and quantizes dense vectors.
§Errors
Returns typed config, vector, duplicate-key, capacity, or allocation errors.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub const fn dimensions(&self) -> usize
pub const fn config(&self) -> &IndexConfig
Sourcepub fn estimated_memory_bytes(&self) -> usize
pub fn estimated_memory_bytes(&self) -> usize
Allocation-based retained size estimate.
Sourcepub fn search(
&self,
query: &[f32],
count: usize,
) -> Result<Vec<SearchHit>, SearchError>
pub fn search( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>
Returns scalar-int8 approximate cosine hits.
§Errors
Returns a typed query validation or allocation error.
Sourcepub fn search_rerank(
&self,
oracle: &VectorIndex,
query: &[f32],
count: usize,
candidates: usize,
) -> Result<Vec<SearchHit>, SearchError>
pub fn search_rerank( &self, oracle: &VectorIndex, query: &[f32], count: usize, candidates: usize, ) -> Result<Vec<SearchHit>, SearchError>
Retrieves a wider quantized candidate set and re-scores it with exact
normalized f32 vectors from oracle.
§Errors
Returns a typed query, missing-key, or allocation error.
Sourcepub fn search_batch(
&self,
queries: &[&[f32]],
count: usize,
) -> Result<Vec<Vec<SearchHit>>, SearchError>
pub fn search_batch( &self, queries: &[&[f32]], count: usize, ) -> Result<Vec<Vec<SearchHit>>, SearchError>
Searches independent queries with bounded workers.
§Errors
Returns the first query error in input order or a worker-panic error.
Trait Implementations§
Source§impl Debug for ScalarQuantizedIndex
impl Debug for ScalarQuantizedIndex
Source§impl SearchShard for ScalarQuantizedIndex
impl SearchShard for ScalarQuantizedIndex
fn dimensions(&self) -> usize
Source§fn search_shard(
&self,
query: &[f32],
count: usize,
) -> Result<Vec<SearchHit>, SearchError>
fn search_shard( &self, query: &[f32], count: usize, ) -> Result<Vec<SearchHit>, SearchError>
Searches this shard. Read more
Auto Trait Implementations§
impl Freeze for ScalarQuantizedIndex
impl RefUnwindSafe for ScalarQuantizedIndex
impl Send for ScalarQuantizedIndex
impl Sync for ScalarQuantizedIndex
impl Unpin for ScalarQuantizedIndex
impl UnsafeUnpin for ScalarQuantizedIndex
impl UnwindSafe for ScalarQuantizedIndex
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