Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Aug 1, 2024
1 parent f43d9c3 commit 2ed49c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions crates/polars-io/src/parquet/read/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ impl ParquetAsyncReader {
self.reader.num_rows().await
}

/// Only positive offsets are supported for simplicity - the caller should
/// translate negative offsets into the positive equivalent.
pub fn with_slice(mut self, slice: Option<(usize, usize)>) -> Self {
self.slice = slice.unwrap_or((0, usize::MAX));
self
Expand Down
11 changes: 10 additions & 1 deletion crates/polars-mem-engine/src/executors/scan/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,17 @@ impl ParquetExec {
if slice.0 >= 0 {
(slice.0 as usize, slice.1.saturating_add(slice.0 as usize))
} else {
// Walk the files in reverse until we find the first file, and then translate the
// slice into a positive-offset equivalent.
let n_from_end = -slice.0 as usize;
let mut cum_rows = 0;
let chunk_size = 8;
POOL.install(|| {
for path_indexes in (0..self.paths.len()).rev().collect::<Vec<_>>().chunks(8) {
for path_indexes in (0..self.paths.len())
.rev()
.collect::<Vec<_>>()
.chunks(chunk_size)
{
let row_counts = path_indexes
.into_par_iter()
.map(|i| {
Expand Down Expand Up @@ -247,6 +254,8 @@ impl ParquetExec {
if slice.0 >= 0 {
(slice.0 as usize, slice.1.saturating_add(slice.0 as usize))
} else {
// Walk the files in reverse until we find the first file, and then translate the
// slice into a positive-offset equivalent.
let n_from_end = -slice.0 as usize;
let mut cum_rows = 0;

Expand Down

0 comments on commit 2ed49c9

Please sign in to comment.