pub struct FlatIndex { /* private fields */ }Expand description
Flat vector index: append-only buffer with brute-force search.
Implementations§
Source§impl FlatIndex
impl FlatIndex
Sourcepub fn new(dim: usize, metric: DistanceMetric) -> Self
pub fn new(dim: usize, metric: DistanceMetric) -> Self
Create a new empty flat index.
Sourcepub fn insert(&mut self, vector: Vec<f32>) -> u32
pub fn insert(&mut self, vector: Vec<f32>) -> u32
Insert a vector. Returns the assigned vector ID.
Sourcepub fn search_with_metric(
&self,
query: &[f32],
top_k: usize,
metric: DistanceMetric,
) -> Vec<SearchResult>
pub fn search_with_metric( &self, query: &[f32], top_k: usize, metric: DistanceMetric, ) -> Vec<SearchResult>
Brute-force k-NN search with an explicit distance metric override.
Overrides the self.metric configured at collection creation time.
Sourcepub fn search(&self, query: &[f32], top_k: usize) -> Vec<SearchResult>
pub fn search(&self, query: &[f32], top_k: usize) -> Vec<SearchResult>
Brute-force k-NN search. Exact results — no approximation.
Sourcepub fn search_filtered(
&self,
query: &[f32],
top_k: usize,
bitmap: &[u8],
) -> Vec<SearchResult>
pub fn search_filtered( &self, query: &[f32], top_k: usize, bitmap: &[u8], ) -> Vec<SearchResult>
Search with a pre-filter bitmap (byte-array format).
Sourcepub fn search_filtered_offset_with_metric(
&self,
query: &[f32],
top_k: usize,
bitmap: &[u8],
id_offset: u32,
metric: DistanceMetric,
) -> Vec<SearchResult>
pub fn search_filtered_offset_with_metric( &self, query: &[f32], top_k: usize, bitmap: &[u8], id_offset: u32, metric: DistanceMetric, ) -> Vec<SearchResult>
Filtered search with an explicit metric override.
Sourcepub fn search_filtered_offset(
&self,
query: &[f32],
top_k: usize,
bitmap: &[u8],
id_offset: u32,
) -> Vec<SearchResult>
pub fn search_filtered_offset( &self, query: &[f32], top_k: usize, bitmap: &[u8], id_offset: u32, ) -> Vec<SearchResult>
Search with a pre-filter bitmap applying a global id offset.
bitmap is a serialized RoaringBitmap (matching the HNSW filter
format). Bit i + id_offset tests local id i. Used by multi-segment
collections where the bitmap holds GLOBAL vector ids. If the bytes
fail to deserialize, the search degrades to unfiltered.
pub fn len(&self) -> usize
pub fn live_count(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get_vector(&self, id: u32) -> Option<&[f32]>
Sourcepub fn get_vector_raw(&self, id: u32) -> Option<&[f32]>
pub fn get_vector_raw(&self, id: u32) -> Option<&[f32]>
Raw access bypassing tombstone filter — used by snapshot/restore.
Sourcepub fn is_deleted(&self, id: u32) -> bool
pub fn is_deleted(&self, id: u32) -> bool
Whether the given local id has been tombstoned.
Sourcepub fn insert_tombstoned(&mut self, vector: Vec<f32>) -> u32
pub fn insert_tombstoned(&mut self, vector: Vec<f32>) -> u32
Insert a vector that is already tombstoned (for checkpoint restore).
pub fn dim(&self) -> usize
pub fn metric(&self) -> DistanceMetric
pub fn tombstone_count(&self) -> usize
Auto Trait Implementations§
impl Freeze for FlatIndex
impl RefUnwindSafe for FlatIndex
impl Send for FlatIndex
impl Sync for FlatIndex
impl Unpin for FlatIndex
impl UnsafeUnpin for FlatIndex
impl UnwindSafe for FlatIndex
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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> 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>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.