mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-23 02:27:40 +08:00
add a bufwriter on the documents
This commit is contained in:
parent
d976e680c5
commit
208c785697
@ -146,7 +146,7 @@ impl UpdateFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct IndexWriter {
|
pub struct IndexWriter {
|
||||||
documents: File,
|
documents: BufWriter<File>,
|
||||||
settings: File,
|
settings: File,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ impl IndexWriter {
|
|||||||
let settings = File::create(path.join("settings.json"))?;
|
let settings = File::create(path.join("settings.json"))?;
|
||||||
|
|
||||||
Ok(IndexWriter {
|
Ok(IndexWriter {
|
||||||
documents,
|
documents: BufWriter::new(documents),
|
||||||
settings,
|
settings,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -169,6 +169,7 @@ impl IndexWriter {
|
|||||||
pub fn push_document(&mut self, document: &Map<String, Value>) -> Result<()> {
|
pub fn push_document(&mut self, document: &Map<String, Value>) -> Result<()> {
|
||||||
self.documents.write_all(&serde_json::to_vec(document)?)?;
|
self.documents.write_all(&serde_json::to_vec(document)?)?;
|
||||||
self.documents.write_all(b"\n")?;
|
self.documents.write_all(b"\n")?;
|
||||||
|
self.documents.flush()?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user