Struct ngt::NgtIndex

source ·
pub struct NgtIndex<T> { /* private fields */ }

Implementations§

source§

impl<T> NgtIndex<T>where T: NgtObjectType,

source

pub fn create<P: AsRef<Path>>(path: P, prop: NgtProperties<T>) -> Result<Self>

Creates an empty ANNG index with the given NgtProperties.

source

pub fn open<P: AsRef<Path>>(path: P) -> Result<Self>

Open the already existing index at the specified path.

source

pub fn search( &self, vec: &[T], res_size: usize, epsilon: f32 ) -> Result<Vec<SearchResult>>

Search the nearest vectors to the specified query vector.

The index must have been built beforehand.

source

pub fn search_query(&self, query: NgtQuery<'_, T>) -> Result<Vec<SearchResult>>

Search the nearest vectors to the specified NgtQuery.

The index must have been built beforehand.

source

pub fn insert(&mut self, vec: Vec<T>) -> Result<VecId>

Insert the specified vector into the index. However note that it is not discoverable yet.

The method build must be called after inserting vectors.

source

pub fn insert_batch(&mut self, batch: Vec<Vec<T>>) -> Result<()>

Insert the multiple vectors into the index. However note that they are not discoverable yet.

The method build must be called after inserting vectors.

source

pub fn build(&mut self, num_threads: usize) -> Result<()>

Build the index for the vectors that have been inserted so far.

source

pub fn persist(&mut self) -> Result<()>

Persist the index to the disk.

source

pub fn remove(&mut self, id: VecId) -> Result<()>

Remove the specified vector.

source

pub fn get_vec(&self, id: VecId) -> Result<Vec<T>>

Get the specified vector.

source

pub fn nb_inserted(&self) -> usize

The number of vectors inserted (but not necessarily indexed).

source

pub fn nb_indexed(&self) -> usize

The number of indexed vectors, available after build.

Trait Implementations§

source§

impl<T: Debug> Debug for NgtIndex<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Drop for NgtIndex<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T> Send for NgtIndex<T>

source§

impl<T> Sync for NgtIndex<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for NgtIndex<T>where T: RefUnwindSafe,

§

impl<T> Unpin for NgtIndex<T>where T: Unpin,

§

impl<T> UnwindSafe for NgtIndex<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.