pub struct Database<T, VS>where
VS: VectorSet<T>,{ /* private fields */ }Expand description
Database.
Implementations§
source§impl<T, VS> Database<T, VS>where
VS: VectorSet<T>,
impl<T, VS> Database<T, VS>where VS: VectorSet<T>,
sourcepub fn num_vectors(&self) -> usize
pub fn num_vectors(&self) -> usize
Returns the number of vectors in the database.
sourcepub const fn vector_size(&self) -> usize
pub const fn vector_size(&self) -> usize
Returns the vector size.
sourcepub const fn num_partitions(&self) -> usize
pub const fn num_partitions(&self) -> usize
Returns the number of partitions.
sourcepub const fn num_divisions(&self) -> usize
pub const fn num_divisions(&self) -> usize
Returns the number of subvector divisions.
sourcepub fn subvector_size(&self) -> usize
pub fn subvector_size(&self) -> usize
Returns the size of a subvector.
sourcepub const fn num_clusters(&self) -> usize
pub const fn num_clusters(&self) -> usize
Returns the number of clusters.
sourcepub fn vector_ids(&self) -> impl Iterator<Item = &Uuid>
pub fn vector_ids(&self) -> impl Iterator<Item = &Uuid>
Returns an iterator of vector IDs.
sourcepub fn partitions(&self) -> PartitionIter<'_, T, VS> ⓘ
pub fn partitions(&self) -> PartitionIter<'_, T, VS> ⓘ
Returns an iterator of partitions.
sourcepub fn get_attribute<K>(
&self,
id: &Uuid,
key: &K
) -> Result<Option<&AttributeValue>, Error>where
String: Borrow<K>,
K: Hash + Eq + ?Sized,
pub fn get_attribute<K>( &self, id: &Uuid, key: &K ) -> Result<Option<&AttributeValue>, Error>where String: Borrow<K>, K: Hash + Eq + ?Sized,
Returns the attribute value of a given vector.
Fails if no vector is associated with id.
sourcepub fn set_attribute_at<KV, KEY, VAL>(
&mut self,
i: usize,
attribute: KV
) -> Result<(), Error>where
KV: Into<(KEY, VAL)>,
KEY: Into<String>,
VAL: Into<AttributeValue>,
pub fn set_attribute_at<KV, KEY, VAL>( &mut self, i: usize, attribute: KV ) -> Result<(), Error>where KV: Into<(KEY, VAL)>, KEY: Into<String>, VAL: Into<AttributeValue>,
Sets an attribute value for the i-th vector.
Replaces with the new value if the vector already has the attribute.
Fails if i is out of bounds.
source§impl<T, VS> Database<T, VS>where
T: Scalar,
VS: VectorSet<T>,
impl<T, VS> Database<T, VS>where T: Scalar, VS: VectorSet<T>,
sourcepub fn query<V>(
&self,
v: &V,
k: NonZeroUsize,
nprobe: NonZeroUsize
) -> Result<Vec<QueryResult<T>>, Error>where
V: AsSlice<T> + ?Sized,
pub fn query<V>( &self, v: &V, k: NonZeroUsize, nprobe: NonZeroUsize ) -> Result<Vec<QueryResult<T>>, Error>where V: AsSlice<T> + ?Sized,
Queries k-nearest neighbors (k-NN) of a given vector.
sourcepub fn query_with_events<V, EventHandler>(
&self,
v: &V,
k: NonZeroUsize,
nprobe: NonZeroUsize,
event: EventHandler
) -> Result<Vec<QueryResult<T>>, Error>where
V: AsSlice<T> + ?Sized,
EventHandler: FnMut(QueryEvent),
pub fn query_with_events<V, EventHandler>( &self, v: &V, k: NonZeroUsize, nprobe: NonZeroUsize, event: EventHandler ) -> Result<Vec<QueryResult<T>>, Error>where V: AsSlice<T> + ?Sized, EventHandler: FnMut(QueryEvent),
Queries k-nearest neighbors (k-NN) of a given vector.
Auto Trait Implementations§
impl<T, VS> RefUnwindSafe for Database<T, VS>where T: RefUnwindSafe, VS: RefUnwindSafe,
impl<T, VS> Send for Database<T, VS>where T: Send, VS: Send,
impl<T, VS> Sync for Database<T, VS>where T: Sync, VS: Sync,
impl<T, VS> Unpin for Database<T, VS>where T: Unpin, VS: Unpin,
impl<T, VS> UnwindSafe for Database<T, VS>where T: UnwindSafe, VS: UnwindSafe,
Blanket Implementations§
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