Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: AsyncReader use BufReader #93

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions fusio-parquet/src/reader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{cmp, ops::Range, sync::Arc};

use bytes::{Bytes, BytesMut};
use fusio::{dynamic::DynFile, Read};
use fusio::{buffered::BufReader, dynamic::DynFile, Read};
use futures::{future::BoxFuture, FutureExt};
use parquet::{
arrow::async_reader::AsyncFileReader,
Expand All @@ -13,9 +13,10 @@ use parquet::{
};

const PREFETCH_FOOTER_SIZE: usize = 512 * 1024;
const DEFAULT_BUFFER_SIZE: usize = 512 * 1024;

pub struct AsyncReader {
inner: Box<dyn DynFile>,
inner: BufReader<Box<dyn DynFile>>,
content_length: u64,
// The prefetch size for fetching file footer.
prefetch_footer_size: usize,
Expand All @@ -29,7 +30,7 @@ fn set_prefetch_footer_size(footer_size: usize, content_size: u64) -> usize {
impl AsyncReader {
pub async fn new(reader: Box<dyn DynFile>, content_length: u64) -> Result<Self, fusio::Error> {
Ok(Self {
inner: reader,
inner: BufReader::new(reader, DEFAULT_BUFFER_SIZE).await?,
content_length,
prefetch_footer_size: set_prefetch_footer_size(PREFETCH_FOOTER_SIZE, content_length),
})
Expand Down
Loading