This commit is contained in:
parent
4c555df8ca
commit
f2fc72056b
@ -160,7 +160,7 @@ async fn read_from_db(id: u32) -> Option<Question> {
|
|||||||
|
|
||||||
match reader.get(index).await {
|
match reader.get(index).await {
|
||||||
Ok(question) => Some(question),
|
Ok(question) => Some(question),
|
||||||
Err(_) => None
|
Err(_) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async fn write_db() {
|
async fn write_db() {
|
||||||
@ -168,7 +168,8 @@ async fn write_db() {
|
|||||||
tokio::try_join!(
|
tokio::try_join!(
|
||||||
tokio::spawn(zip_reader_task(tx)),
|
tokio::spawn(zip_reader_task(tx)),
|
||||||
tokio::spawn(db_writer_task(rx))
|
tokio::spawn(db_writer_task(rx))
|
||||||
).expect("tokio join");
|
)
|
||||||
|
.expect("tokio join");
|
||||||
println!("all done");
|
println!("all done");
|
||||||
}
|
}
|
||||||
async fn db_writer_task(rx: UnboundedReceiver<Question>) {
|
async fn db_writer_task(rx: UnboundedReceiver<Question>) {
|
||||||
|
@ -59,7 +59,7 @@ where
|
|||||||
let out = fs::File::create(path).await.str_err()?;
|
let out = fs::File::create(path).await.str_err()?;
|
||||||
let out = io::BufWriter::with_capacity(opts.out_buf_size, out);
|
let out = io::BufWriter::with_capacity(opts.out_buf_size, out);
|
||||||
let data_buf: Vec<u8> = Vec::with_capacity(opts.data_buf_size);
|
let data_buf: Vec<u8> = Vec::with_capacity(opts.data_buf_size);
|
||||||
|
|
||||||
let compress_lvl = opts.compress_lvl;
|
let compress_lvl = opts.compress_lvl;
|
||||||
|
|
||||||
let table: Vec<LSize> = vec![];
|
let table: Vec<LSize> = vec![];
|
||||||
@ -79,8 +79,10 @@ where
|
|||||||
let item_data = bincode::encode_to_vec(item, BINCODE_CFG).str_err()?;
|
let item_data = bincode::encode_to_vec(item, BINCODE_CFG).str_err()?;
|
||||||
|
|
||||||
let mut zencoder = ZstdEncoder::with_quality(&item_data[..], self.compress_lvl);
|
let mut zencoder = ZstdEncoder::with_quality(&item_data[..], self.compress_lvl);
|
||||||
io::copy(&mut zencoder, &mut self.data_buf).await.str_err()?;
|
io::copy(&mut zencoder, &mut self.data_buf)
|
||||||
|
.await
|
||||||
|
.str_err()?;
|
||||||
|
|
||||||
self.table.push(pos);
|
self.table.push(pos);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user