Skip to content

Commit

Permalink
Stop zeroing buffers in the local file storage.
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed Mar 11, 2024
1 parent 81e4f1b commit 616e18a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion quickwit/quickwit-storage/src/file_descriptor_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ impl SplitFile {
use std::os::unix::fs::FileExt;
let file = self.clone();
let buf = tokio::task::spawn_blocking(move || {
let mut buf = vec![0u8; range.len()];
let mut buf = Vec::with_capacity(range.len());
unsafe {
buf.set_len(range.len());
}
file.0.file.read_exact_at(&mut buf, range.start as u64)?;
io::Result::Ok(buf)
})
Expand Down
5 changes: 4 additions & 1 deletion quickwit/quickwit-storage/src/local_file_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ impl Storage for LocalFileStorage {
// step, as there would be if using tokio async File.
let mut file = std::fs::File::open(full_path)?;
file.seek(SeekFrom::Start(range.start as u64))?;
let mut content_bytes: Vec<u8> = vec![0u8; range.len()];
let mut content_bytes: Vec<u8> = Vec::with_capacity(range.len());
unsafe {
content_bytes.set_len(range.len());
}
file.read_exact(&mut content_bytes)?;
Ok(OwnedBytes::new(content_bytes))
})
Expand Down

0 comments on commit 616e18a

Please sign in to comment.