pub struct IdMap<I> { /* private fields */ }
Expand description
Wrapper for implementing arbitrary ID mapping to an index.
See the module level documentation for more information.
Implementations
sourceimpl<I> IdMap<I> where
I: NativeIndex,
impl<I> IdMap<I> where
I: NativeIndex,
sourcepub fn index_inner_ptr(&self) -> *mut FaissIndex
pub fn index_inner_ptr(&self) -> *mut FaissIndex
Obtain the raw pointer to the internal index.
Safety
While this method is safe, note that the returned index pointer is
already owned by this ID map. Therefore, it is undefined behavior to
create a high-level index value from this pointer without first
decoupling this ownership. See [into_inner
] for a safe alternative.
sourcepub fn into_inner(self) -> I where
I: FromInnerPtr,
pub fn into_inner(self) -> I where
I: FromInnerPtr,
Discard the ID map, recovering the index originally created without it.
sourcepub fn try_into_inner(self) -> Result<I> where
I: TryFromInnerPtr,
pub fn try_into_inner(self) -> Result<I> where
I: TryFromInnerPtr,
Discard the ID map, recovering the index originally created without it. Safety build managed index from pointer.
sourcepub fn try_cast_inner_index<B>(self) -> Result<IdMap<B>> where
B: TryFromInnerPtr,
pub fn try_cast_inner_index<B>(self) -> Result<IdMap<B>> where
B: TryFromInnerPtr,
Specialization of the index type inside IdMap
.
Trait Implementations
sourceimpl<I> ConcurrentIndex for IdMap<I> where
I: ConcurrentIndex,
impl<I> ConcurrentIndex for IdMap<I> where
I: ConcurrentIndex,
sourcefn assign(&self, query: &[f32], k: usize) -> Result<AssignSearchResult>
fn assign(&self, query: &[f32], k: usize) -> Result<AssignSearchResult>
Similar to search
, but only provides the labels.
sourcefn search(&self, query: &[f32], k: usize) -> Result<SearchResult>
fn search(&self, query: &[f32], k: usize) -> Result<SearchResult>
Perform a search for the k
closest vectors to the given query vectors.
sourcefn range_search(&self, query: &[f32], radius: f32) -> Result<RangeSearchResult>
fn range_search(&self, query: &[f32], radius: f32) -> Result<RangeSearchResult>
Perform a ranged search for the vectors closest to the given query vectors by the given radius. Read more
sourceimpl<I> Index for IdMap<I>
impl<I> Index for IdMap<I>
sourcefn is_trained(&self) -> bool
fn is_trained(&self) -> bool
Whether the Index does not require training, or if training is done already
sourcefn metric_type(&self) -> MetricType
fn metric_type(&self) -> MetricType
The metric type assumed by the index
sourcefn add(&mut self, x: &[f32]) -> Result<()>
fn add(&mut self, x: &[f32]) -> Result<()>
Add new data vectors to the index.
This assumes a C-contiguous memory slice of vectors, where the total
number of vectors is x.len() / d
. Read more
sourcefn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>
fn add_with_ids(&mut self, x: &[f32], xids: &[Idx]) -> Result<()>
Add new data vectors to the index with IDs.
This assumes a C-contiguous memory slice of vectors, where the total
number of vectors is x.len() / d
.
Not all index types may support this operation. Read more
sourcefn assign(&mut self, query: &[f32], k: usize) -> Result<AssignSearchResult>
fn assign(&mut self, query: &[f32], k: usize) -> Result<AssignSearchResult>
Similar to search
, but only provides the labels.
sourcefn search(&mut self, query: &[f32], k: usize) -> Result<SearchResult>
fn search(&mut self, query: &[f32], k: usize) -> Result<SearchResult>
Perform a search for the k
closest vectors to the given query vectors.
sourcefn range_search(
&mut self,
query: &[f32],
radius: f32
) -> Result<RangeSearchResult>
fn range_search(
&mut self,
query: &[f32],
radius: f32
) -> Result<RangeSearchResult>
Perform a ranged search for the vectors closest to the given query vectors by the given radius. Read more
sourcefn remove_ids(&mut self, sel: &IdSelector) -> Result<usize>
fn remove_ids(&mut self, sel: &IdSelector) -> Result<usize>
Remove data vectors represented by IDs.
sourcefn set_verbose(&mut self, value: bool)
fn set_verbose(&mut self, value: bool)
Set Index verbosity level
sourceimpl<I> NativeIndex for IdMap<I>
impl<I> NativeIndex for IdMap<I>
sourcefn inner_ptr(&self) -> *mut FaissIndex
fn inner_ptr(&self) -> *mut FaissIndex
Retrieve a pointer to the native index object.
impl<I: CpuIndex> CpuIndex for IdMap<I>
impl<I: Send> Send for IdMap<I>
impl<I: Sync> Sync for IdMap<I>
Auto Trait Implementations
impl<I> RefUnwindSafe for IdMap<I> where
I: RefUnwindSafe,
impl<I> Unpin for IdMap<I> where
I: Unpin,
impl<I> UnwindSafe for IdMap<I> where
I: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more