pub struct Writer<D: Distance> { /* private fields */ }Expand description
A writer to store new items, remove existing ones, and build the search index to query the nearest neighbors to items or vectors.
Implementations§
Source§impl<D: Distance> Writer<D>
impl<D: Distance> Writer<D>
Sourcepub fn new(database: Database<D>, index: u16, dimensions: usize) -> Writer<D>
pub fn new(database: Database<D>, index: u16, dimensions: usize) -> Writer<D>
Creates a new writer from a database, index and dimensions.
Sourcepub fn prepare_changing_distance<ND: Distance>(
self,
wtxn: &mut RwTxn<'_>,
) -> Result<Writer<ND>>
pub fn prepare_changing_distance<ND: Distance>( self, wtxn: &mut RwTxn<'_>, ) -> Result<Writer<ND>>
Returns a writer after having deleted the tree nodes and rewrote all the items
for the new Distance format to be able to modify items safely.
Sourcepub fn set_tmpdir(&mut self, path: impl Into<PathBuf>)
pub fn set_tmpdir(&mut self, path: impl Into<PathBuf>)
Sets the path to the temporary directory where files are written.
Sourcepub fn need_build(&self, rtxn: &RoTxn<'_>) -> Result<bool>
pub fn need_build(&self, rtxn: &RoTxn<'_>) -> Result<bool>
Returns true if the index needs to be built before being able to read in it.
Sourcepub fn item_vector(
&self,
rtxn: &RoTxn<'_>,
item: ItemId,
) -> Result<Option<Vec<f32>>>
pub fn item_vector( &self, rtxn: &RoTxn<'_>, item: ItemId, ) -> Result<Option<Vec<f32>>>
Returns an Optional vector previous stored in this database.
Sourcepub fn contains_item(&self, rtxn: &RoTxn<'_>, item: ItemId) -> Result<bool>
pub fn contains_item(&self, rtxn: &RoTxn<'_>, item: ItemId) -> Result<bool>
Returns true if the database contains the given item.
Sourcepub fn iter<'t>(&self, rtxn: &'t RoTxn<'_>) -> Result<ItemIter<'t, D>>
pub fn iter<'t>(&self, rtxn: &'t RoTxn<'_>) -> Result<ItemIter<'t, D>>
Returns an iterator over the items vector.
Sourcepub fn add_item(
&self,
wtxn: &mut RwTxn<'_>,
item: ItemId,
vector: &[f32],
) -> Result<()>
pub fn add_item( &self, wtxn: &mut RwTxn<'_>, item: ItemId, vector: &[f32], ) -> Result<()>
Add an item associated to a vector in the database.
Sourcepub fn del_item(&self, wtxn: &mut RwTxn<'_>, item: ItemId) -> Result<bool>
pub fn del_item(&self, wtxn: &mut RwTxn<'_>, item: ItemId) -> Result<bool>
Deletes an item stored in this database and returns true if it existed.
Sourcepub fn clear(&self, wtxn: &mut RwTxn<'_>) -> Result<()>
pub fn clear(&self, wtxn: &mut RwTxn<'_>) -> Result<()>
Removes everything in the database, user items and internal graph links.
Sourcepub fn builder<'a, R>(
&'a self,
rng: &'a mut R,
) -> HannoyBuilder<'a, D, R, NoProgress>where
R: Rng + SeedableRng,
pub fn builder<'a, R>(
&'a self,
rng: &'a mut R,
) -> HannoyBuilder<'a, D, R, NoProgress>where
R: Rng + SeedableRng,
Returns an HannoyBuilder to configure the available options to build the database.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Writer<D>
impl<D> RefUnwindSafe for Writer<D>where
D: RefUnwindSafe,
impl<D> Send for Writer<D>
impl<D> Sync for Writer<D>
impl<D> Unpin for Writer<D>where
D: Unpin,
impl<D> UnwindSafe for Writer<D>where
D: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§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> 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>
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>
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 more