Struct faiss::index::flat::FlatIndexImpl

source ·
pub struct FlatIndexImpl { /* private fields */ }
Expand description

Native implementation of a flat index.

Implementations§

source§

impl FlatIndexImpl

source

pub fn new(d: u32, metric: MetricType) -> Result<Self>

Create a new flat index.

source

pub fn new_l2(d: u32) -> Result<Self>

Create a new flat index with L2 as the metric type.

source

pub fn new_ip(d: u32) -> Result<Self>

Create a new flat index with IP (inner product) as the metric type.

source

pub fn xb(&self) -> &[f32]

Obtain a reference to the indexed data.

source

pub fn compute_distance_subset( &mut self, x: &[f32], labels: &[Idx] ) -> Result<Vec<f32>>

Compute distance with a subset of vectors. x is a sequence of query vectors, size n * d, where n is inferred from the length of x. labels is a sequence of indexed vector ID’s that should be compared for each query vector, size n * k, where k is inferred from the length of labels. Returns the corresponding output distances, size n * k.

source§

impl FlatIndexImpl

source

pub fn to_gpu<'gpu, G>( &self, gpu_res: &'gpu G, device: i32 ) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where G: GpuResourcesProvider,

Build a GPU in from the given CPU native index, yielding two independent indices. The operation fails if the index does not provide GPU support.

source

pub fn into_gpu<'gpu, G>( self, gpu_res: &'gpu G, device: i32 ) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where G: GpuResourcesProvider,

Build a GPU index from the given CPU native index, discarding the CPU-backed index. The operation fails if the index does not provide GPU support.

source

pub fn to_gpu_multiple<'gpu, G>( &self, gpu_res: &'gpu [G], devices: &[i32] ) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where G: GpuResourcesProvider + 'gpu,

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.

source

pub fn into_gpu_multiple<'gpu, G>( self, gpu_res: &'gpu [G], devices: &[i32] ) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where G: GpuResourcesProvider + 'gpu,

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§

source§

impl ConcurrentIndex for FlatIndexImplwhere Self: Index + NativeIndex,

source§

fn assign(&self, query: &[f32], k: usize) -> Result<AssignSearchResult>

Similar to search, but only provides the labels.
source§

fn search(&self, query: &[f32], k: usize) -> Result<SearchResult>

Perform a search for the k closest vectors to the given query vectors.
Perform a ranged search for the vectors closest to the given query vectors by the given radius.
source§

impl Debug for FlatIndexImpl

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for FlatIndexImpl

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl FromInnerPtr for FlatIndexImpl

source§

unsafe fn from_inner_ptr(inner_ptr: *mut FaissIndex) -> Self

Create an index using the given pointer to a native object. Read more
source§

impl NativeIndex for FlatIndexImpl

source§

fn inner_ptr(&self) -> *mut FaissIndex

Retrieve a pointer to the native index object.
source§

impl TryClone for FlatIndexImpl

source§

fn try_clone(&self) -> Result<Self>where Self: Sized,

Create an independent clone of this index. Read more
source§

impl TryFromInnerPtr for FlatIndexImpl

source§

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
source§

impl CpuIndex for FlatIndexImpl

source§

impl Send for FlatIndexImpl

source§

impl Sync for FlatIndexImpl

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<NI> UpcastIndex for NIwhere NI: NativeIndex,

source§

fn upcast(self) -> IndexImpl

Convert an index to the base IndexImpl type