pub struct TieredIndex { /* private fields */ }Expand description
Tiered vector index with binary, int8, and optional fp32 representations
Implementations§
Source§impl TieredIndex
impl TieredIndex
Sourcepub fn new(dim: usize) -> TieredIndex
pub fn new(dim: usize) -> TieredIndex
Create a new tiered index (no memory limit)
Sourcepub fn with_fp32_storage(dim: usize) -> TieredIndex
pub fn with_fp32_storage(dim: usize) -> TieredIndex
Create with fp32 storage for maximum precision rescoring
Sourcepub fn with_capacity(
dim: usize,
capacity: usize,
store_fp32: bool,
) -> TieredIndex
pub fn with_capacity( dim: usize, capacity: usize, store_fp32: bool, ) -> TieredIndex
Create with pre-allocated capacity
Sourcepub fn memory_constrained(dim: usize, max_bytes: usize) -> TieredIndex
pub fn memory_constrained(dim: usize, max_bytes: usize) -> TieredIndex
Create a memory-constrained index for resource-limited systems
Automatically calculates the maximum number of vectors that fit in the given memory budget.
§Example
// For a system with 512 MB available for vectors
let index = TieredIndex::memory_constrained(1024, 512 * 1024 * 1024);
// For 1 GB budget
let index = TieredIndex::memory_constrained(768, 1024 * 1024 * 1024);
// Using helper constants
let index = TieredIndex::memory_constrained(1024, TieredIndex::MB(256));Sourcepub fn memory_constrained_precise(dim: usize, max_bytes: usize) -> TieredIndex
pub fn memory_constrained_precise(dim: usize, max_bytes: usize) -> TieredIndex
Create memory-constrained index with fp32 storage
Note: fp32 storage uses 4x more memory per vector.
Sourcepub fn is_constrained(&self) -> bool
pub fn is_constrained(&self) -> bool
Check if the index has a memory constraint
Sourcepub fn memory_constraint(&self) -> Option<&MemoryConstraint>
pub fn memory_constraint(&self) -> Option<&MemoryConstraint>
Get the memory constraint configuration (if any)
Sourcepub fn remaining_capacity(&self) -> Option<usize>
pub fn remaining_capacity(&self) -> Option<usize>
Get remaining capacity (vectors)
Sourcepub fn remaining_bytes(&self) -> Option<usize>
pub fn remaining_bytes(&self) -> Option<usize>
Get remaining memory budget (bytes)
Sourcepub fn memory_utilization(&self) -> Option<f32>
pub fn memory_utilization(&self) -> Option<f32>
Get memory utilization as percentage (0.0 - 1.0)
Sourcepub fn add(&mut self, vector: &[f32]) -> bool
pub fn add(&mut self, vector: &[f32]) -> bool
Add a vector to the index
Automatically quantizes to binary and int8 representations.
Returns false if memory limit reached (for constrained indexes).
Sourcepub fn add_unchecked(&mut self, vector: &[f32])
pub fn add_unchecked(&mut self, vector: &[f32])
Add a vector, panicking if memory limit reached
Use this when you’re sure there’s capacity.
Sourcepub fn try_add(&mut self, vector: &[f32]) -> Result<(), MemoryLimitError>
pub fn try_add(&mut self, vector: &[f32]) -> Result<(), MemoryLimitError>
Try to add a vector, returning error details if failed
Sourcepub fn add_batch(&mut self, vectors: &[Vec<f32>]) -> usize
pub fn add_batch(&mut self, vectors: &[Vec<f32>]) -> usize
Add multiple vectors in batch
Returns the number of vectors successfully added.
Sourcepub fn add_batch_partial(&mut self, vectors: &[Vec<f32>]) -> (usize, usize)
pub fn add_batch_partial(&mut self, vectors: &[Vec<f32>]) -> (usize, usize)
Add multiple vectors, stopping at memory limit
Returns (added_count, remaining_vectors)
Sourcepub fn memory_stats(&self) -> TieredMemoryStats
pub fn memory_stats(&self) -> TieredMemoryStats
Get memory usage statistics
Sourcepub fn search(&self, query: &[f32], k: usize) -> Vec<TieredSearchResult>
pub fn search(&self, query: &[f32], k: usize) -> Vec<TieredSearchResult>
Search for k nearest neighbors using tiered retrieval
Uses default configuration (rescore_multiplier=4, no fp32 final).
Sourcepub fn search_with_config(
&self,
query: &[f32],
k: usize,
config: &TieredSearchConfig,
) -> Vec<TieredSearchResult>
pub fn search_with_config( &self, query: &[f32], k: usize, config: &TieredSearchConfig, ) -> Vec<TieredSearchResult>
Search with custom configuration
Sourcepub fn search_binary_only(
&self,
query: &[f32],
k: usize,
) -> Vec<TieredSearchResult>
pub fn search_binary_only( &self, query: &[f32], k: usize, ) -> Vec<TieredSearchResult>
Search with only binary (fastest, least precise)
Sourcepub fn search_int8(
&self,
query: &[f32],
k: usize,
rescore_multiplier: usize,
) -> Vec<TieredSearchResult>
pub fn search_int8( &self, query: &[f32], k: usize, rescore_multiplier: usize, ) -> Vec<TieredSearchResult>
Search with binary + int8 (recommended balance)
Auto Trait Implementations§
impl Freeze for TieredIndex
impl RefUnwindSafe for TieredIndex
impl Send for TieredIndex
impl Sync for TieredIndex
impl Unpin for TieredIndex
impl UnsafeUnpin for TieredIndex
impl UnwindSafe for TieredIndex
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
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 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>
T in a tonic::Request