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
source§impl FlatIndexImpl
impl FlatIndexImpl
sourcepub fn to_gpu<'gpu, G>(
&self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResources,
pub fn to_gpu<'gpu, G>(
&self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResources,
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: GpuResources,
pub fn into_gpu<'gpu, G>(
self,
gpu_res: &'gpu G,
device: i32
) -> Result<GpuIndexImpl<'gpu, FlatIndexImpl>>where
G: GpuResources,
Build a GPU in from the given CPU native index, discarding the CPU-backed index. The operation fails if the index does not provide GPU support.
Trait Implementations§
source§impl ConcurrentIndex for FlatIndexImpl
impl ConcurrentIndex for FlatIndexImpl
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.