Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
1f93a93
update
XiangpengHao Jul 1, 2025
2e01e56
update
XiangpengHao Jul 1, 2025
0bd08c3
update
XiangpengHao Jul 1, 2025
d6ecbd4
update
XiangpengHao Jul 1, 2025
7cd5518
cleanup
XiangpengHao Jul 2, 2025
4520048
update
XiangpengHao Jul 2, 2025
e6281bc
update
XiangpengHao Jul 2, 2025
6b6d4fc
update
XiangpengHao Jul 2, 2025
b696b66
update
XiangpengHao Jul 2, 2025
f60581f
update
XiangpengHao Jul 2, 2025
1851f0b
clippy and license
XiangpengHao Jul 2, 2025
5e414a8
Merge remote-tracking branch 'apache/main' into pushdown-v4
alamb Jul 7, 2025
58add51
bug fix
XiangpengHao Jul 8, 2025
470cc01
Merge remote-tracking branch 'refs/remotes/origin/pushdown-v3' into p…
XiangpengHao Jul 8, 2025
2bf3d38
clippy
XiangpengHao Jul 8, 2025
2cf1a8f
bug fix
XiangpengHao Jul 8, 2025
86e149c
switch to boolean array for row selection
XiangpengHao Jul 15, 2025
4d24172
Merge remote-tracking branch 'apache/main' into pushdown-v4
alamb Jul 15, 2025
be134d6
Add comments (OCD) and rename some fields
alamb Jul 15, 2025
eecaf99
Merge pull request #4 from alamb/alamb/pushdown_suggestions
XiangpengHao Jul 15, 2025
5537bcb
fmt
XiangpengHao Jul 15, 2025
b835163
fmt
alamb Jul 16, 2025
5132de8
Simplify projection caching
alamb Jul 16, 2025
253dad3
Move cache options construction to ArrayReaderBuilder, add builders
alamb Jul 16, 2025
5d9781e
update memory accounting
XiangpengHao Jul 17, 2025
2e20902
Merge remote-tracking branch 'refs/remotes/origin/pushdown-v4' into p…
XiangpengHao Jul 17, 2025
721d00c
Merge pull request #5 from alamb/alamb/simplify_cache
XiangpengHao Jul 17, 2025
f8aed80
Merge pull request #6 from alamb/alamb/cleaner_api
XiangpengHao Jul 17, 2025
884b591
update
XiangpengHao Jul 17, 2025
4f6b918
array size
XiangpengHao Jul 17, 2025
6c53bfd
add test case
XiangpengHao Jul 17, 2025
8ebe579
fix bug
XiangpengHao Jul 17, 2025
c240a52
clippy & fmt
XiangpengHao Jul 17, 2025
30a0d1c
Add config option for predicate cache memory limit
alamb Jul 23, 2025
ed3ce13
Add option to control predicate cache, documentation, ArrowReaderMetr…
alamb Jul 23, 2025
42d5520
Update parquet/src/arrow/arrow_reader/mod.rs
alamb Jul 24, 2025
6e618b3
Merge pull request #7 from alamb/alamb/test_memory_limit
XiangpengHao Jul 24, 2025
f70e46a
Clarify in documentation that cache is only for async decoder
alamb Jul 25, 2025
15d6826
add comment
alamb Jul 25, 2025
bec6d9c
Revert backwards incompatible changes to the Parquet reader API
alamb Jul 25, 2025
3e05cb2
Merge pull request #9 from alamb/alamb/revert_api_changes
XiangpengHao Jul 25, 2025
4d64dc0
Merge pull request #8 from alamb/alamb/pushdown-v4-cleanup
XiangpengHao Jul 25, 2025
8da582b
Merge remote-tracking branch 'apache/main' into pushdown-v4
alamb Aug 6, 2025
315e463
exclude nested column from cache
XiangpengHao Aug 7, 2025
1db701a
only use expanded selection when the column is one of cache column
XiangpengHao Aug 7, 2025
bea4433
Merge remote-tracking branch 'upstream/main' into pushdown-v4
XiangpengHao Aug 7, 2025
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
Prev Previous commit
Next Next commit
bug fix
  • Loading branch information
XiangpengHao committed Jul 8, 2025
commit 2cf1a8f82f722e1c7e4857d7b07ba726f67d9f2f
37 changes: 31 additions & 6 deletions parquet/src/arrow/array_reader/cached_array_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl ArrayReader for CachedArrayReader {
let cached = if let Some(array) = self.local_buffer.get(&batch_id) {
Some(array.clone())
} else {
// If not in local cache, check shared cache
// If not in local cache, i.e., we are consumer, check shared cache
let shared_cached = self.cache.lock().unwrap().get(self.column_idx, batch_id);
if let Some(array) = shared_cached.as_ref() {
// Store in local cache for later use in consume_batch
Expand All @@ -200,20 +200,21 @@ impl ArrayReader for CachedArrayReader {
match cached {
Some(array) => {
let array_len = array.len();
if array_len + batch_id.val * self.batch_size - self.outer_position > 0 {
if array_len + batch_id.val * self.batch_size - self.outer_position - read > 0 {
// the cache batch has some records that we can select
let v = array_len + batch_id.val * self.batch_size - self.outer_position;
let v =
array_len + batch_id.val * self.batch_size - self.outer_position - read;
let select_cnt = std::cmp::min(num_records - read, v);
read += select_cnt;
self.selections.push_back(RowSelector::select(select_cnt));
self.outer_position += select_cnt;
} else {
// this is last batch and we have used all records from it
break;
}
}
None => {
let read_from_inner = self.fetch_batch(batch_id)?;

// Reached end-of-file, no more records to read
if read_from_inner == 0 {
break;
Expand All @@ -225,14 +226,14 @@ impl ArrayReader for CachedArrayReader {
read += select_from_this_batch;
self.selections
.push_back(RowSelector::select(select_from_this_batch));
self.outer_position += select_from_this_batch;
if read_from_inner < self.batch_size {
// this is last batch from inner reader
break;
}
}
}
}
self.outer_position += read;
Ok(read)
}

Expand Down Expand Up @@ -294,7 +295,12 @@ impl ArrayReader for CachedArrayReader {
}

self.selections.clear();
self.local_buffer.clear();

// Only remove batches from local buffer that are completely behind current position
// Keep the current batch and any future batches as they might still be needed
let current_batch_id = self.get_batch_id_from_position(self.outer_position);
self.local_buffer
.retain(|batch_id, _| batch_id.val >= current_batch_id.val);

// For consumers, cleanup batches that have been completely consumed
// This reduces the memory usage of the shared cache
Expand Down Expand Up @@ -634,4 +640,23 @@ mod tests {
// Local cache should be cleared after consume_batch
assert!(cached_reader.local_buffer.is_empty());
}

#[test]
fn test_local_cache_is_cleared_properly() {
let mock_reader = MockArrayReader::new(vec![1, 2, 3, 4]);
let cache = Arc::new(Mutex::new(RowGroupCache::new(3, Some(0)))); // Batch size 3, cache 0
let mut cached_reader =
CachedArrayReader::new(Box::new(mock_reader), cache.clone(), 0, CacheRole::Consumer);

// Read records which should populate both shared and local cache
let records_read = cached_reader.read_records(1).unwrap();
assert_eq!(records_read, 1);
let array = cached_reader.consume_batch().unwrap();
assert_eq!(array.len(), 1);

let records_read = cached_reader.read_records(3).unwrap();
assert_eq!(records_read, 3);
let array = cached_reader.consume_batch().unwrap();
assert_eq!(array.len(), 3);
}
}
Loading