From 317b1b0621b297f52145b41b90506632f2dc7a1d Mon Sep 17 00:00:00 2001 From: Kould Date: Thu, 26 Sep 2024 11:49:56 +0800 Subject: [PATCH] fix: async reader read miss (#26) --- fusio-parquet/src/reader.rs | 9 ++++++--- fusio/src/lib.rs | 3 +-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fusio-parquet/src/reader.rs b/fusio-parquet/src/reader.rs index 8c57f1e..aaf7d0b 100644 --- a/fusio-parquet/src/reader.rs +++ b/fusio-parquet/src/reader.rs @@ -46,7 +46,8 @@ impl AsyncFileReader for AsyncReader { fn get_bytes(&mut self, range: Range) -> BoxFuture<'_, parquet::errors::Result> { async move { let len = range.end - range.start; - let buf = BytesMut::with_capacity(len); + let mut buf = BytesMut::with_capacity(len); + buf.resize(len, 0); self.inner .seek(range.start as u64) @@ -65,7 +66,8 @@ impl AsyncFileReader for AsyncReader { fn get_metadata(&mut self) -> BoxFuture<'_, parquet::errors::Result>> { async move { let footer_size = self.prefetch_footer_size; - let buf = BytesMut::with_capacity(footer_size); + let mut buf = BytesMut::with_capacity(footer_size); + buf.resize(footer_size, 0); self.inner .seek(self.content_length - footer_size as u64) @@ -101,7 +103,8 @@ impl AsyncFileReader for AsyncReader { .await .map_err(|err| ParquetError::External(Box::new(err)))?; - let buf = BytesMut::with_capacity(metadata_length); + let mut buf = BytesMut::with_capacity(metadata_length); + buf.resize(metadata_length, 0); let bytes = self .inner diff --git a/fusio/src/lib.rs b/fusio/src/lib.rs index a0a7d4c..3ed863f 100644 --- a/fusio/src/lib.rs +++ b/fusio/src/lib.rs @@ -10,8 +10,7 @@ pub mod remotes; use std::{future::Future, io::Cursor}; -pub use buf::IoBuf; -pub use buf::IoBufMut; +pub use buf::{IoBuf, IoBufMut}; #[cfg(all(feature = "dyn", feature = "fs"))] pub use dynamic::fs::DynFs; #[cfg(feature = "dyn")]