Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Fix the compilation error of the dependency versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerollmops committed Mar 14, 2022
1 parent 2812fa2 commit 092e6cd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
25 changes: 13 additions & 12 deletions milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ impl CboRoaringBitmapCodec {
buffer.extend_from_slice(&integer.to_ne_bytes());
}
} else {
let roaring = RoaringBitmap::from_sorted_iter(vec.into_iter());
// Integers *must* be ordered here, no matter what.
let roaring = RoaringBitmap::from_sorted_iter(vec.into_iter()).unwrap();
roaring.serialize_into(buffer)?;
}
} else {
Expand Down Expand Up @@ -152,25 +153,25 @@ mod tests {
let mut buffer = Vec::new();

let small_data = vec![
RoaringBitmap::from_sorted_iter(1..4),
RoaringBitmap::from_sorted_iter(2..5),
RoaringBitmap::from_sorted_iter(4..6),
RoaringBitmap::from_sorted_iter(1..3),
RoaringBitmap::from_sorted_iter(1..4).unwrap(),
RoaringBitmap::from_sorted_iter(2..5).unwrap(),
RoaringBitmap::from_sorted_iter(4..6).unwrap(),
RoaringBitmap::from_sorted_iter(1..3).unwrap(),
];

let small_data: Vec<_> =
small_data.iter().map(|b| CboRoaringBitmapCodec::bytes_encode(b).unwrap()).collect();
CboRoaringBitmapCodec::merge_into(small_data.as_slice(), &mut buffer).unwrap();
let bitmap = CboRoaringBitmapCodec::deserialize_from(&buffer).unwrap();
let expected = RoaringBitmap::from_sorted_iter(1..6);
let expected = RoaringBitmap::from_sorted_iter(1..6).unwrap();
assert_eq!(bitmap, expected);

let medium_data = vec![
RoaringBitmap::from_sorted_iter(1..4),
RoaringBitmap::from_sorted_iter(2..5),
RoaringBitmap::from_sorted_iter(4..8),
RoaringBitmap::from_sorted_iter(0..3),
RoaringBitmap::from_sorted_iter(7..23),
RoaringBitmap::from_sorted_iter(1..4).unwrap(),
RoaringBitmap::from_sorted_iter(2..5).unwrap(),
RoaringBitmap::from_sorted_iter(4..8).unwrap(),
RoaringBitmap::from_sorted_iter(0..3).unwrap(),
RoaringBitmap::from_sorted_iter(7..23).unwrap(),
];

let medium_data: Vec<_> =
Expand All @@ -179,7 +180,7 @@ mod tests {
CboRoaringBitmapCodec::merge_into(medium_data.as_slice(), &mut buffer).unwrap();

let bitmap = CboRoaringBitmapCodec::deserialize_from(&buffer).unwrap();
let expected = RoaringBitmap::from_sorted_iter(0..23);
let expected = RoaringBitmap::from_sorted_iter(0..23).unwrap();
assert_eq!(bitmap, expected);
}
}
6 changes: 4 additions & 2 deletions milli/src/search/criteria/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ fn query_pair_proximity_docids(
#[cfg(test)]
pub mod test {
use std::collections::HashMap;
use std::iter;

use maplit::hashmap;
use rand::rngs::StdRng;
Expand Down Expand Up @@ -567,7 +568,8 @@ pub mod test {
.iter()
.enumerate()
.map(|(i, w)| {
(w.clone(), RoaringBitmap::from_sorted_iter(std::iter::once(i as u32)))
let bitmap = RoaringBitmap::from_sorted_iter(iter::once(i as u32)).unwrap();
(w.clone(), bitmap)
})
.collect())
} else {
Expand Down Expand Up @@ -622,7 +624,7 @@ pub mod test {
}
values.sort_unstable();

RoaringBitmap::from_sorted_iter(values.into_iter())
RoaringBitmap::from_sorted_iter(values.into_iter()).unwrap()
}

let word_docids = hashmap! {
Expand Down
3 changes: 1 addition & 2 deletions milli/src/search/query_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,7 @@ mod test {
values.push(rng.gen());
}
values.sort_unstable();

RoaringBitmap::from_sorted_iter(values.into_iter())
RoaringBitmap::from_sorted_iter(values.into_iter()).unwrap()
}

TestContext {
Expand Down
6 changes: 3 additions & 3 deletions milli/src/update/delete_documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {

// We create the FST map of the external ids that we must delete.
external_ids.sort_unstable();
let external_ids_to_delete = fst::Set::from_iter(external_ids.iter().map(AsRef::as_ref))?;
let external_ids_to_delete = fst::Set::from_iter(external_ids)?;

// We acquire the current external documents ids map...
let mut new_external_documents_ids = self.index.external_documents_ids(self.wtxn)?;
Expand All @@ -209,7 +209,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
// the LMDB B-Tree two times but only once.
let mut iter = word_docids.prefix_iter_mut(self.wtxn, &word)?;
if let Some((key, mut docids)) = iter.next().transpose()? {
if key == word.as_ref() {
if key == word.as_str() {
let previous_len = docids.len();
docids -= &self.documents_ids;
if docids.is_empty() {
Expand All @@ -230,7 +230,7 @@ impl<'t, 'u, 'i> DeleteDocuments<'t, 'u, 'i> {
words.iter().filter_map(
|(word, must_remove)| {
if *must_remove {
Some(word.as_ref())
Some(word.as_str())
} else {
None
}
Expand Down

0 comments on commit 092e6cd

Please sign in to comment.