justinli500 commented on code in PR #49855:
URL: https://github.com/apache/arrow/pull/49855#discussion_r3726236858


##########
cpp/src/parquet/arrow/reader.cc:
##########
@@ -1275,10 +1239,31 @@ 
FileReaderImpl::GetRecordBatchGenerator(std::shared_ptr<FileReader> reader,
                        reader_properties_.cache_options());
     END_PARQUET_CATCH_EXCEPTIONS
   }
+  // GH-39808: evict each row group's bytes as the decoded prefix advances, so
+  // memory stays bounded. Only this read-once path evicts, so PreBuffer()'s
+  // contract is unchanged for other callers.
+  std::shared_ptr<ReadCacheEvictionState> eviction_state;
+  if (reader_properties_.pre_buffer() && !column_indices.empty() &&
+      !row_group_indices.empty()) {
+    const int64_t kNoMoreRanges = std::numeric_limits<int64_t>::max();
+    std::vector<int64_t> evict_before(row_group_indices.size() + 1, 
kNoMoreRanges);
+    for (int64_t i = static_cast<int64_t>(row_group_indices.size()) - 1; i >= 
0; --i) {

Review Comment:
   Just added this to the API docs. Any order is safe, but file order frees 
memory sooner. I also noted that automatic eviction is meant for one-pass reads.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to