@@ -220,7 +220,7 @@ index 4d3acb491e..3906ff3c59 100644
220220
221221--- a/cpp/src/parquet/file_reader.cc
222222+++ b/cpp/src/parquet/file_reader.cc
223- @@ -207,6 +207,100 @@
223+ @@ -207,6 +207,117 @@
224224 return {col_start, col_length};
225225 }
226226
@@ -308,6 +308,23 @@ index 4d3acb491e..3906ff3c59 100644
308308+ return std::shared_ptr<::arrow::Buffer>(std::move(buf));
309309+ }
310310+
311+ + // Override Advance to avoid real I/O for skipped pages.
312+ + // The default InputStream::Advance() calls Read() and discards the result,
313+ + // which would trigger source_->ReadAt() on cache miss — defeating page-level
314+ + // I/O skipping via data_page_filter. Since Advance() is only used to skip
315+ + // over data that will not be consumed, we can safely just move the position.
316+ + ::arrow::Status Advance(int64_t nbytes) override {
317+ + if (nbytes <= 0) {
318+ + return ::arrow::Status::OK();
319+ + }
320+ + int64_t remaining = length_ - position_;
321+ + if (remaining <= 0) {
322+ + return ::arrow::Status::OK();
323+ + }
324+ + position_ += std::min(nbytes, remaining);
325+ + return ::arrow::Status::OK();
326+ + }
327+ +
311328+ private:
312329+ std::shared_ptr<::arrow::io::internal::ReadRangeCache> cache_;
313330+ std::shared_ptr<ArrowInputFile> source_;
@@ -321,7 +338,7 @@ index 4d3acb491e..3906ff3c59 100644
321338 // RowGroupReader::Contents implementation for the Parquet file specification
322339 class SerializedRowGroup : public RowGroupReader::Contents {
323340 public:
324- @@ -242,6 +336 ,11 @@
341+ @@ -242,6 +343 ,11 @@
325342 // segments.
326343 PARQUET_ASSIGN_OR_THROW(auto buffer, cached_source_->Read(col_range));
327344 stream = std::make_shared<::arrow::io::BufferReader>(buffer);
@@ -333,7 +350,7 @@ index 4d3acb491e..3906ff3c59 100644
333350 } else {
334351 stream = properties_.GetStream(source_, col_range.offset, col_range.length);
335352 }
336- @@ -417,6 +516 ,26 @@
353+ @@ -417,6 +523 ,26 @@
337354 return cached_source_->WaitFor(ranges);
338355 }
339356
@@ -360,7 +377,7 @@ index 4d3acb491e..3906ff3c59 100644
360377 // Metadata/footer parsing. Divided up to separate sync/async paths, and to use
361378 // exceptions for error handling (with the async path converting to Future/Status).
362379
363- @@ -911,6 +1030 ,22 @@
380+ @@ -911,6 +1037 ,22 @@
364381 return file->WhenBuffered(row_groups, column_indices);
365382 }
366383
@@ -410,3 +427,13 @@ diff --git a/cpp/cmake_modules/BuildUtils.cmake b/cpp/cmake_modules/BuildUtils.c
410427 message(FATAL_ERROR "libtool found appears to be the incompatible GNU libtool: ${LIBTOOL_MACOS}"
411428 )
412429 endif()
430+
431+ diff --git a/cpp/src/arrow/io/interfaces.h b/cpp/src/arrow/io/interfaces.h
432+ --- a/cpp/src/arrow/io/interfaces.h
433+ +++ b/cpp/src/arrow/io/interfaces.h
434+ @@ -211,7 +211,7 @@
435+ /// \brief Advance or skip stream indicated number of bytes
436+ /// \param[in] nbytes the number to move forward
437+ /// \return Status
438+ - Status Advance(int64_t nbytes);
439+ + virtual Status Advance(int64_t nbytes);
0 commit comments