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

feat: impl parallel get_byte_ranges for ObjectStoreReader #449

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
30 changes: 29 additions & 1 deletion analytic_engine/src/sst/parquet/async_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ use common_types::{
};
use common_util::{runtime::Runtime, time::InstantExt};
use datafusion::datasource::file_format;
use futures::{future::BoxFuture, FutureExt, Stream, StreamExt, TryFutureExt};
use futures::{
future::{try_join_all, BoxFuture},
FutureExt, Stream, StreamExt, TryFutureExt,
};
use log::{debug, error, info};
use object_store::{ObjectMeta, ObjectStoreRef, Path};
use parquet::{
Expand Down Expand Up @@ -239,6 +242,31 @@ impl AsyncFileReader for ObjectStoreReader {
.boxed()
}

fn get_byte_ranges(
&mut self,
ranges: Vec<Range<usize>>,
) -> BoxFuture<'_, parquet::errors::Result<Vec<Bytes>>> {
let mut futures = Vec::with_capacity(ranges.len());
for range in ranges {
let storage = self.storage.clone();
let path = self.path.clone();
self.metrics.bytes_scanned += range.end - range.start;
futures.push(async move {
storage
.get_range(&path, range)
.map_err(|e| {
parquet::errors::ParquetError::General(format!(
"ObjectStoreReader::get_bytes error: {}",
e
))
})
.await
});
}

try_join_all(futures).boxed()
}

fn get_metadata(
&mut self,
) -> BoxFuture<'_, parquet::errors::Result<Arc<parquet::file::metadata::ParquetMetaData>>> {
Expand Down