Make sure we always use a BufWriter to write the update files

This commit is contained in:
Clément Renault 2024-09-11 18:38:04 +02:00
parent e7d9db078f
commit 0d868f36d7
No known key found for this signature in database
GPG Key ID: F250A4C4E3AE5F5F

View File

@ -244,10 +244,11 @@ pub fn read_json(input: &File, output: impl io::Write) -> Result<u64> {
} }
/// Reads NDJSON from file and write it in NDJSON in a file checking it along the way. /// Reads NDJSON from file and write it in NDJSON in a file checking it along the way.
pub fn read_ndjson(input: &File, mut output: impl io::Write) -> Result<u64> { pub fn read_ndjson(input: &File, output: impl io::Write) -> Result<u64> {
// We memory map to be able to deserailize into a TopLevelMap<'pl> that // We memory map to be able to deserailize into a TopLevelMap<'pl> that
// does not allocate when possible and only materialize the first/top level. // does not allocate when possible and only materialize the first/top level.
let input = unsafe { Mmap::map(input).map_err(DocumentFormatError::Io)? }; let input = unsafe { Mmap::map(input).map_err(DocumentFormatError::Io)? };
let mut output = BufWriter::new(output);
let mut count = 0; let mut count = 0;
for result in serde_json::Deserializer::from_slice(&input).into_iter() { for result in serde_json::Deserializer::from_slice(&input).into_iter() {