Struct arroy::Reader

source ·
pub struct Reader<'t, D: Distance> { /* private fields */ }
Expand description

A reader over the arroy trees and user items.

Implementations§

source§

impl<'t, D: Distance> Reader<'t, D>

source

pub fn open( rtxn: &'t RoTxn<'_>, index: u16, database: Database<D> ) -> Result<Reader<'t, D>>

Returns a reader over the database with the specified Distance type.

source

pub fn dimensions(&self) -> usize

Returns the number of dimensions in the index.

source

pub fn n_trees(&self) -> usize

Returns the number of trees in the index.

source

pub fn n_items(&self) -> u64

Returns the number of vectors stored in the index.

source

pub fn index(&self) -> u16

Returns the index of this reader in the database.

source

pub fn stats(&self, rtxn: &RoTxn<'_>) -> Result<Stats>

Returns the stats of the trees of this database.

source

pub fn n_nodes(&self, rtxn: &'t RoTxn<'_>) -> Result<Option<NonZeroUsize>>

Returns the number of nodes in the index. Useful to run an exhaustive search.

source

pub fn item_vector( &self, rtxn: &'t RoTxn<'_>, item: ItemId ) -> Result<Option<Vec<f32>>>

Returns the vector for item i that was previously added.

source

pub fn is_empty(&self, rtxn: &RoTxn<'_>) -> Result<bool>

Returns true if the index is empty.

source

pub fn contains_item(&self, rtxn: &RoTxn<'_>, item: ItemId) -> Result<bool>

Returns true if the database contains the given item.

source

pub fn iter(&self, rtxn: &'t RoTxn<'_>) -> Result<ItemIter<'t, D>>

Returns an iterator over the items vector.

source

pub fn nns_by_item( &self, rtxn: &'t RoTxn<'_>, item: ItemId, count: usize, search_k: Option<NonZeroUsize>, candidates: Option<&RoaringBitmap> ) -> Result<Option<Vec<(ItemId, f32)>>>

Returns the count closests items from item.

During the query it will inspect up to search_k nodes which defaults to n_trees * count if not provided. search_k gives you a run-time tradeoff between better accuracy and speed.

The candidates parameter corresponds to the subset of item ids arroy will return.

source

pub fn nns_by_vector( &self, rtxn: &'t RoTxn<'_>, vector: &[f32], count: usize, search_k: Option<NonZeroUsize>, candidates: Option<&RoaringBitmap> ) -> Result<Vec<(ItemId, f32)>>

Returns the count closest items from the provided vector.

See Reader::nns_by_item for more details.

Trait Implementations§

source§

impl<'t, D: Debug + Distance> Debug for Reader<'t, D>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'t, D> RefUnwindSafe for Reader<'t, D>
where D: RefUnwindSafe,

§

impl<'t, D> Send for Reader<'t, D>

§

impl<'t, D> Sync for Reader<'t, D>

§

impl<'t, D> Unpin for Reader<'t, D>
where D: Unpin,

§

impl<'t, D> UnwindSafe for Reader<'t, D>
where D: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where 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 T
where 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V