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

Use BufReader for LocalFileReader to revert performance regression in parquet reading #1366

Merged
merged 7 commits into from
Nov 27, 2021
Merged
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: 5 additions & 2 deletions datafusion/src/datasource/object_store/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Object store that represents the Local File System.

use std::fs::{self, File, Metadata};
use std::io::{Read, Seek, SeekFrom};
use std::io::{BufReader, Read, Seek, SeekFrom};
use std::sync::Arc;

use async_trait::async_trait;
Expand Down Expand Up @@ -87,7 +87,10 @@ impl ObjectReader for LocalFileReader {
// This okay because chunks are usually fairly large.
let mut file = File::open(&self.file.path)?;
file.seek(SeekFrom::Start(start))?;
Ok(Box::new(file.take(length as u64)))

let file = BufReader::new(file.take(length as u64));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this is the actual fix, right? Is the change to require the BufRead trait needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Rerunning some benchmarks now without the trait.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - looks like BufRead wasn't needed 🎉


Ok(Box::new(file))
}

fn length(&self) -> u64 {
Expand Down