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 15, 2022
1 parent 63682c2 commit 21ec334
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
1 change: 1 addition & 0 deletions http-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ futures = "0.3.21"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = { version = "1.0.79", features = ["preserve_order"] }
tokio = { version = "1.17.0", features = ["full"] }
tokio-stream = { version = "0.1.8", default-features = false, features = ["sync"] }
warp = "0.3.2"

# logging
Expand Down
9 changes: 5 additions & 4 deletions http-ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ mod update_store;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt::Display;
use std::fs::{create_dir_all, File};
use std::io::{BufRead, BufReader, Cursor};
use std::io::{BufRead, BufReader, Cursor, Read};
use std::net::SocketAddr;
use std::num::{NonZeroU32, NonZeroUsize};
use std::path::PathBuf;
Expand Down Expand Up @@ -35,6 +35,7 @@ use structopt::StructOpt;
use tokio::fs::File as TFile;
use tokio::io::AsyncWriteExt;
use tokio::sync::broadcast;
use tokio_stream::wrappers::BroadcastStream;
use warp::filters::ws::Message;
use warp::http::Response;
use warp::Filter;
Expand Down Expand Up @@ -885,7 +886,8 @@ async fn main() -> anyhow::Result<()> {
let mut file = TFile::from_std(file);

while let Some(result) = stream.next().await {
let bytes = result.unwrap().to_bytes();
let mut bytes = Vec::new();
result.unwrap().reader().read_to_end(&mut bytes).unwrap();
file.write_all(&bytes[..]).await.unwrap();
}

Expand Down Expand Up @@ -1004,8 +1006,7 @@ async fn main() -> anyhow::Result<()> {
let update_status_receiver = update_status_sender.subscribe();
ws.on_upgrade(|websocket| {
// Just echo all updates messages...
update_status_receiver
.into_stream()
BroadcastStream::new(update_status_receiver)
.flat_map(|result| match result {
Ok(status) => {
let msg = serde_json::to_string(&status).unwrap();
Expand Down
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 21ec334

Please sign in to comment.