mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
get rids of the useless Seek before creating a grenad reader
This commit is contained in:
parent
83f3c5ec57
commit
9fe24fbff2
@ -15,7 +15,7 @@ pub mod route_metrics;
|
||||
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{BufReader, BufWriter, Seek, SeekFrom},
|
||||
io::{BufReader, BufWriter},
|
||||
path::Path,
|
||||
sync::{atomic::AtomicBool, Arc},
|
||||
};
|
||||
@ -227,15 +227,16 @@ fn import_dump(
|
||||
// 3.3 Import the documents.
|
||||
// 3.3.1 We need to recreate the grenad+obkv format accepted by the index.
|
||||
log::info!("Importing the documents.");
|
||||
let mut file = tempfile::tempfile()?;
|
||||
let mut builder = DocumentsBatchBuilder::new(BufWriter::new(&mut file));
|
||||
let file = tempfile::tempfile()?;
|
||||
let mut builder = DocumentsBatchBuilder::new(BufWriter::new(file));
|
||||
for document in index_reader.documents()? {
|
||||
builder.append_json_object(&document?)?;
|
||||
}
|
||||
builder.into_inner()?; // this actually flush the content of the batch builder.
|
||||
|
||||
// This flush the content of the batch builder.
|
||||
let file = builder.into_inner()?.into_inner()?;
|
||||
|
||||
// 3.3.2 We feed it to the milli index.
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
let reader = BufReader::new(file);
|
||||
let reader = DocumentsBatchReader::from_reader(reader)?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user