pub struct FlatIndex { /* private fields */ }Expand description
Flat index using brute-force search.
Provides exact nearest neighbor results but O(n) per query.
Implementations§
Source§impl FlatIndex
impl FlatIndex
Sourcepub fn new(config: IndexConfig) -> Self
pub fn new(config: IndexConfig) -> Self
Create a new flat index.
Sourcepub fn with_capacity(config: IndexConfig, capacity: usize) -> Self
pub fn with_capacity(config: IndexConfig, capacity: usize) -> Self
Create with specified capacity.
Sourcepub const fn with_parallel(self, parallel: bool) -> Self
pub const fn with_parallel(self, parallel: bool) -> Self
Enable/disable parallel search.
Sourcepub const fn with_parallel_threshold(self, threshold: usize) -> Self
pub const fn with_parallel_threshold(self, threshold: usize) -> Self
Set parallel threshold.
Trait Implementations§
Source§impl VectorIndex for FlatIndex
impl VectorIndex for FlatIndex
Source§fn add(&mut self, id: String, vector: &[f32]) -> Result<()>
fn add(&mut self, id: String, vector: &[f32]) -> Result<()>
Add a vector to the index. Read more
Source§fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
fn search(&self, query: &[f32], k: usize) -> Result<Vec<SearchResult>>
Search for k nearest neighbors. Read more
Source§fn distance_type(&self) -> DistanceType
fn distance_type(&self) -> DistanceType
Distance type used by this index.
Source§fn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Get memory usage estimate in bytes.
Source§fn add_batch(&mut self, ids: Vec<String>, vectors: &[Vec<f32>]) -> Result<()>
fn add_batch(&mut self, ids: Vec<String>, vectors: &[Vec<f32>]) -> Result<()>
Add multiple vectors in batch. Read more
Source§fn search_with_ids(
&self,
query: &[f32],
k: usize,
ids: &[String],
) -> Result<Vec<SearchResult>>
fn search_with_ids( &self, query: &[f32], k: usize, ids: &[String], ) -> Result<Vec<SearchResult>>
Search with pre-filter (IDs to consider). Read more
Auto Trait Implementations§
impl Freeze for FlatIndex
impl RefUnwindSafe for FlatIndex
impl Send for FlatIndex
impl Sync for FlatIndex
impl Unpin for FlatIndex
impl UnwindSafe for FlatIndex
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.