pub struct IndexImpl { /* private fields */ }
Expand description
Native implementation of a Faiss Index running on the CPU.
Implementations
sourceimpl IndexImpl
impl IndexImpl
sourcepub fn as_flat(self) -> Result<FlatIndexImpl>
👎 Deprecated since 0.8.0: Non-idiomatic name, prefer into_flat
instead
pub fn as_flat(self) -> Result<FlatIndexImpl>
Non-idiomatic name, prefer into_flat
instead
Attempt a dynamic cast of an index to the flat index type.
sourcepub fn into_flat(self) -> Result<FlatIndexImpl>
pub fn into_flat(self) -> Result<FlatIndexImpl>
Attempt a dynamic cast of an index to the flat index type.
sourceimpl IndexImpl
impl IndexImpl
sourcepub fn into_ivf_flat(self) -> Result<IVFFlatIndexImpl>
pub fn into_ivf_flat(self) -> Result<IVFFlatIndexImpl>
Attempt a dynamic cast of an index to the IVF flat index type.
sourceimpl IndexImpl
impl IndexImpl
pub fn into_pre_transform(self) -> Result<PreTransformIndexImpl<IndexImpl>>
sourceimpl IndexImpl
impl IndexImpl
sourcepub fn into_scalar_quantizer(self) -> Result<ScalarQuantizerIndexImpl>
pub fn into_scalar_quantizer(self) -> Result<ScalarQuantizerIndexImpl>
Attempt a dynamic cast of an index to the Scalar Quantizer index type.
sourceimpl IndexImpl
impl IndexImpl
sourcepub fn into_ivf_scalar_quantizer(
self
) -> Result<IVFScalarQuantizerIndexImpl<IndexImpl>>
pub fn into_ivf_scalar_quantizer(
self
) -> Result<IVFScalarQuantizerIndexImpl<IndexImpl>>
Attempt a dynamic cast of an index to the IVF Scalar Quantizer index type.
sourceimpl IndexImpl
impl IndexImpl
sourcepub fn to_gpu<'gpu, G: 'gpu>(
&self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
pub fn to_gpu<'gpu, G: 'gpu>(
&self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
Build a GPU index from the given CPU native index.
Errors
The operation fails if the index type does not provide GPU support.
sourcepub fn into_gpu<'gpu, G: 'gpu>(
self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
pub fn into_gpu<'gpu, G: 'gpu>(
self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
Build a GPU index from the given CPU native index. The index residing in CPU memory is discarded in the process.
Errors
The operation fails if the index does not provide GPU support.
sourcepub fn to_gpu_multiple<'gpu, G: 'gpu>(
&self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
pub fn to_gpu_multiple<'gpu, G: 'gpu>(
&self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
Build a GPU index from the given CPU native index.
Errors
The operation fails if the number of GPU resources and number of devices do not match, or the index does not provide GPU support.
sourcepub fn into_gpu_multiple<'gpu, G: 'gpu>(
self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
pub fn into_gpu_multiple<'gpu, G: 'gpu>(
self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, IndexImpl>> where
G: GpuResourcesProvider,
Build a GPU index from the given CPU native index. The index residing in CPU memory is discarded in the process.
Errors
The operation fails if the number of GPU resources and number of devices do not match, or the index does not provide GPU support.
Trait Implementations
sourceimpl FromInnerPtr for IndexImpl
impl FromInnerPtr for IndexImpl
sourceunsafe fn from_inner_ptr(inner_ptr: *mut FaissIndex) -> Self
unsafe fn from_inner_ptr(inner_ptr: *mut FaissIndex) -> Self
Create an index using the given pointer to a native object. Read more
sourceimpl Index for IndexImpl
impl Index for IndexImpl
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 NativeIndex for IndexImpl
impl NativeIndex for IndexImpl
sourcefn inner_ptr(&self) -> *mut FaissIndex
fn inner_ptr(&self) -> *mut FaissIndex
Retrieve a pointer to the native index object.
sourceimpl TryFromInnerPtr for IndexImpl
impl TryFromInnerPtr for IndexImpl
sourceunsafe fn try_from_inner_ptr(inner_ptr: *mut FaissIndex) -> Result<Self> where
Self: Sized,
unsafe fn try_from_inner_ptr(inner_ptr: *mut FaissIndex) -> Result<Self> where
Self: Sized,
Create an index using the given pointer to a native object,
checking that the index behind the given pointer
is compatible with the target index type.
If the inner index is not compatible with the intended target type
(e.g. creating a FlatIndex
out of a FaissIndexLSH
),
an error is returned. Read more
impl CpuIndex for IndexImpl
impl Send for IndexImpl
impl Sync for IndexImpl
Auto Trait Implementations
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