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>
impl<'t, D: Distance> Reader<'t, D>
sourcepub fn open(
rtxn: &'t RoTxn<'_>,
index: u16,
database: Database<D>
) -> Result<Reader<'t, D>>
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.
sourcepub fn dimensions(&self) -> usize
pub fn dimensions(&self) -> usize
Returns the number of dimensions in the index.
sourcepub fn stats(&self, rtxn: &RoTxn<'_>) -> Result<Stats>
pub fn stats(&self, rtxn: &RoTxn<'_>) -> Result<Stats>
Returns the stats of the trees of this database.
sourcepub fn n_nodes(&self, rtxn: &'t RoTxn<'_>) -> Result<Option<NonZeroUsize>>
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.
sourcepub fn item_vector(
&self,
rtxn: &'t RoTxn<'_>,
item: ItemId
) -> Result<Option<Vec<f32>>>
pub fn item_vector( &self, rtxn: &'t RoTxn<'_>, item: ItemId ) -> Result<Option<Vec<f32>>>
Returns the vector for item i
that was previously added.
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(&self, rtxn: &'t RoTxn<'_>) -> Result<ItemIter<'t, D>>
pub fn iter(&self, rtxn: &'t RoTxn<'_>) -> Result<ItemIter<'t, D>>
Returns an iterator over the items vector.
sourcepub fn nns_by_item(
&self,
rtxn: &'t RoTxn<'_>,
item: ItemId,
count: usize,
search_k: Option<NonZeroUsize>,
candidates: Option<&RoaringBitmap>
) -> Result<Option<Vec<(ItemId, f32)>>>
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.
sourcepub fn nns_by_vector(
&self,
rtxn: &'t RoTxn<'_>,
vector: &[f32],
count: usize,
search_k: Option<NonZeroUsize>,
candidates: Option<&RoaringBitmap>
) -> Result<Vec<(ItemId, f32)>>
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.