pub struct IndexRegistry { /* private fields */ }Expand description
Thread-safe registry for managing multiple named indexes.
§Example
ⓘ
use rag_plusplus_core::index::{IndexRegistry, FlatIndex, IndexConfig};
let mut registry = IndexRegistry::new();
// Register indexes for different modalities
let text_index = FlatIndex::new(IndexConfig::new(768));
let code_index = FlatIndex::new(IndexConfig::new(512));
registry.register("text_embeddings", text_index)?;
registry.register("code_embeddings", code_index)?;
// Search specific index
let results = registry.search("text_embeddings", &query, 10)?;
// Search all indexes
let all_results = registry.search_all(&query, 10)?;Implementations§
Source§impl IndexRegistry
impl IndexRegistry
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create registry with pre-allocated capacity.
Sourcepub fn register<I: VectorIndex + 'static>(
&mut self,
name: impl Into<String>,
index: I,
) -> Result<()>
pub fn register<I: VectorIndex + 'static>( &mut self, name: impl Into<String>, index: I, ) -> Result<()>
Register a new index with the given name.
§Errors
Returns error if an index with the same name already exists.
Sourcepub fn register_or_replace<I: VectorIndex + 'static>(
&mut self,
name: impl Into<String>,
index: I,
) -> Option<Box<dyn VectorIndex>>
pub fn register_or_replace<I: VectorIndex + 'static>( &mut self, name: impl Into<String>, index: I, ) -> Option<Box<dyn VectorIndex>>
Register or replace an index.
Returns the previous index if one existed.
Sourcepub fn get(&self, name: &str) -> Option<&dyn VectorIndex>
pub fn get(&self, name: &str) -> Option<&dyn VectorIndex>
Get a reference to an index by name.
Sourcepub fn remove(&mut self, name: &str) -> Option<Box<dyn VectorIndex>>
pub fn remove(&mut self, name: &str) -> Option<Box<dyn VectorIndex>>
Remove an index by name.
Returns the removed index if it existed.
Sourcepub fn total_vectors(&self) -> usize
pub fn total_vectors(&self) -> usize
Total number of vectors across all indexes.
Sourcepub fn total_memory(&self) -> usize
pub fn total_memory(&self) -> usize
Total memory usage across all indexes.
Sourcepub fn search_all(&self, query: &[f32], k: usize) -> Result<MultiIndexResults>
pub fn search_all(&self, query: &[f32], k: usize) -> Result<MultiIndexResults>
Search all indexes with the same query.
Note: This is a sequential search. For parallel search, use parallel_search_all.
§Errors
Returns error if any search fails.
Sourcepub fn search_indexes(
&self,
names: &[&str],
query: &[f32],
k: usize,
) -> Result<MultiIndexResults>
pub fn search_indexes( &self, names: &[&str], query: &[f32], k: usize, ) -> Result<MultiIndexResults>
Trait Implementations§
Source§impl Debug for IndexRegistry
impl Debug for IndexRegistry
Source§impl Default for IndexRegistry
impl Default for IndexRegistry
Source§fn default() -> IndexRegistry
fn default() -> IndexRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IndexRegistry
impl !RefUnwindSafe for IndexRegistry
impl Send for IndexRegistry
impl Sync for IndexRegistry
impl Unpin for IndexRegistry
impl !UnwindSafe for IndexRegistry
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.