Skip to content

Commit 67e74b8

Browse files
authored
Merge pull request #78 from meilisearch/expose-the-known-universe
Add a method on reader to get all the item ids
2 parents 8aaeae7 + 4b43f6d commit 67e74b8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/reader.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ impl<'t, D: Distance> Reader<'t, D> {
7474
self.items.len()
7575
}
7676

77+
/// Returns all the item ids contained in this index.
78+
pub fn item_ids(&self) -> &RoaringBitmap {
79+
&self.items
80+
}
81+
7782
/// Returns the index of this reader in the database.
7883
pub fn index(&self) -> u16 {
7984
self.index

src/tests/reader.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,23 @@ fn two_dimension_on_a_column() {
169169
"###);
170170
}
171171

172+
#[test]
173+
fn get_item_ids() {
174+
let handle = create_database();
175+
let mut wtxn = handle.env.write_txn().unwrap();
176+
let writer = Writer::new(handle.database, 0, 2);
177+
for i in 0..10 {
178+
writer.add_item(&mut wtxn, i, &[0.0, i as f32]).unwrap();
179+
}
180+
181+
writer.build(&mut wtxn, &mut rng(), Some(50)).unwrap();
182+
183+
let reader = Reader::<Euclidean>::open(&wtxn, 0, handle.database).unwrap();
184+
let ret = reader.item_ids();
185+
186+
insta::assert_debug_snapshot!(ret, @"RoaringBitmap<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]>");
187+
}
188+
172189
#[test]
173190
fn filtering() {
174191
let handle = create_database();

0 commit comments

Comments
 (0)