Struct faiss::index::flat::FlatIndexImpl
source · pub struct FlatIndexImpl { /* private fields */ }
Expand description
Native implementation of a flat index.
Implementations§
source§impl FlatIndexImpl
impl FlatIndexImpl
sourcepub fn new(d: u32, metric: MetricType) -> Result<Self>
pub fn new(d: u32, metric: MetricType) -> Result<Self>
Create a new flat index.
sourcepub fn new_ip(d: u32) -> Result<Self>
pub fn new_ip(d: u32) -> Result<Self>
Create a new flat index with IP (inner product) as the metric type.
sourcepub fn compute_distance_subset(
&mut self,
x: &[f32],
labels: &[Idx]
) -> Result<Vec<f32>>
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
impl FlatIndexImpl
sourcepub fn to_gpu<'gpu, G>(
&self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResourcesProvider,
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.
sourcepub fn into_gpu<'gpu, G>(
self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResourcesProvider,
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.
sourcepub fn to_gpu_multiple<'gpu, G>(
&self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResourcesProvider + 'gpu,
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.
sourcepub fn into_gpu_multiple<'gpu, G>(
self,
gpu_res: &'gpu [G],
devices: &[i32]
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResourcesProvider + 'gpu,
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,
impl ConcurrentIndex for FlatIndexImplwhere Self: Index + NativeIndex,
source§fn assign(&self, query: &[f32], k: usize) -> Result<AssignSearchResult>
fn assign(&self, query: &[f32], k: usize) -> Result<AssignSearchResult>
search
, but only provides the labels.source§fn search(&self, query: &[f32], k: usize) -> Result<SearchResult>
fn search(&self, query: &[f32], k: usize) -> Result<SearchResult>
k
closest vectors to the given query vectors.source§fn range_search(&self, query: &[f32], radius: f32) -> Result<RangeSearchResult>
fn range_search(&self, query: &[f32], radius: f32) -> Result<RangeSearchResult>
source§impl Debug for FlatIndexImpl
impl Debug for FlatIndexImpl
source§impl Drop for FlatIndexImpl
impl Drop for FlatIndexImpl
source§impl FromInnerPtr for FlatIndexImpl
impl FromInnerPtr for FlatIndexImpl
source§unsafe fn from_inner_ptr(inner_ptr: *mut FaissIndex) -> Self
unsafe fn from_inner_ptr(inner_ptr: *mut FaissIndex) -> Self
source§impl NativeIndex for FlatIndexImpl
impl NativeIndex for FlatIndexImpl
source§fn inner_ptr(&self) -> *mut FaissIndex
fn inner_ptr(&self) -> *mut FaissIndex
source§impl TryClone for FlatIndexImpl
impl TryClone for FlatIndexImpl
source§impl TryFromInnerPtr for FlatIndexImpl
impl TryFromInnerPtr for FlatIndexImpl
source§unsafe 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,
FlatIndex
out of a FaissIndexLSH
),
an error is returned. Read more