Skip to content

Commit

Permalink
Implement AsyncFileReader for Box<dyn AsyncFileReader> (#2368)
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Aug 10, 2022
1 parent d4ad4b7 commit 53dd5aa
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions parquet/src/arrow/async_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ pub trait AsyncFileReader: Send {
fn get_metadata(&mut self) -> BoxFuture<'_, Result<Arc<ParquetMetaData>>>;
}

impl AsyncFileReader for Box<dyn AsyncFileReader> {
fn get_bytes(&mut self, range: Range<usize>) -> BoxFuture<'_, Result<Bytes>> {
self.as_mut().get_bytes(range)
}

fn get_byte_ranges(
&mut self,
ranges: Vec<Range<usize>>,
) -> BoxFuture<'_, Result<Vec<Bytes>>> {
self.as_mut().get_byte_ranges(ranges)
}

fn get_metadata(&mut self) -> BoxFuture<'_, Result<Arc<ParquetMetaData>>> {
self.as_mut().get_metadata()
}
}

impl<T: AsyncRead + AsyncSeek + Unpin + Send> AsyncFileReader for T {
fn get_bytes(&mut self, range: Range<usize>) -> BoxFuture<'_, Result<Bytes>> {
async move {
Expand Down

0 comments on commit 53dd5aa

Please sign in to comment.