mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-02-16 23:43:27 +01: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::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::{BufReader, BufWriter, Seek, SeekFrom},
|
io::{BufReader, BufWriter},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
};
|
};
|
||||||
@ -227,15 +227,16 @@ fn import_dump(
|
|||||||
// 3.3 Import the documents.
|
// 3.3 Import the documents.
|
||||||
// 3.3.1 We need to recreate the grenad+obkv format accepted by the index.
|
// 3.3.1 We need to recreate the grenad+obkv format accepted by the index.
|
||||||
log::info!("Importing the documents.");
|
log::info!("Importing the documents.");
|
||||||
let mut file = tempfile::tempfile()?;
|
let file = tempfile::tempfile()?;
|
||||||
let mut builder = DocumentsBatchBuilder::new(BufWriter::new(&mut file));
|
let mut builder = DocumentsBatchBuilder::new(BufWriter::new(file));
|
||||||
for document in index_reader.documents()? {
|
for document in index_reader.documents()? {
|
||||||
builder.append_json_object(&document?)?;
|
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.
|
// 3.3.2 We feed it to the milli index.
|
||||||
file.seek(SeekFrom::Start(0))?;
|
|
||||||
let reader = BufReader::new(file);
|
let reader = BufReader::new(file);
|
||||||
let reader = DocumentsBatchReader::from_reader(reader)?;
|
let reader = DocumentsBatchReader::from_reader(reader)?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user