Skip to content

refractor(parquet): simplify FileReaderWrapper and PageFilteredRowGroupReader with unified TargetRowGroup structure#334

Open
zhf999 wants to merge 16 commits into
alibaba:mainfrom
zhf999:zhf-refractor
Open

refractor(parquet): simplify FileReaderWrapper and PageFilteredRowGroupReader with unified TargetRowGroup structure#334
zhf999 wants to merge 16 commits into
alibaba:mainfrom
zhf999:zhf-refractor

Conversation

@zhf999
Copy link
Copy Markdown
Contributor

@zhf999 zhf999 commented Jun 3, 2026

Purpose

Linked issue: N/A
Pevious PR #330, please review #330 first.

Refactor FileReaderWrapper and PageFilteredRowGroupReader to improve readability, reduce code duplication, and simplify the calling interface:

  1. Unify redundant member variables into TargetRowGroup struct — Replace scattered target_row_group_indices_, row_group_row_ranges_, page_filtered_indices_ with a single std::vector<TargetRowGroup> that carries row group index, page-filter flag, and row ranges together.
    The TargetRowGroup stuct is define as follows:
struct TargetRowGroup {
    int32_t row_group_index;
    bool is_page_filtered;
    // page-filtered row ranges, only valid if is_page_filtered is true.
    RowRanges row_ranges;
};
  1. Simplify SetReadRanges calling chain — Introduce FileReaderWrapper::ApplyReadRanges() that directly mutates target_row_groups_ in-place, eliminating the round-trip through FilterRowGroupsByReadRanges → rebuild → PrepareForReadingLazy. Remove read_row_groups_ and read_column_indices_ from ParquetFileBatchReader.

  2. Split long methods into focused helpers — Break PrepareForReading() (~120 lines), Next() (~100 lines), and SeekToRow() into smaller single-responsibility methods:

    • AdvanceToNextRowGroup(), NextPageFiltered(), NextFullyMatched()
    • BuildPageFilteredSchema(), CollectPreBufferRanges(), DispatchPreBuffer()
  3. Refactor PageFilteredRowGroupReader — Extract GetPageRowRange() (eliminating 3x duplicated page row-range calculation), WaitForPreBuffer(), ExecuteSkipReadPattern(). Use TargetRowGroup in ReadFilteredRowGroup and ComputePageRanges signatures to reduce parameter count.

Tests

  • All existing unit tests in paimon-parquet-format-test pass without modification to test logic (only call-site syntax adapted).
  • Key test suites: FileReaderWrapperTest, PageFilteredRowGroupReaderTest, ParquetFileBatchReaderTest.

API and Format

  • FileReaderWrapper::PrepareForReading / PrepareForReadingLazy now accept std::vector<TargetRowGroup> instead of std::set<int32_t>.
  • FileReaderWrapper::FilterRowGroupsByReadRanges removed, replaced by ApplyReadRanges.
  • PageFilteredRowGroupReader::ReadFilteredRowGroup / ComputePageRanges now accept const TargetRowGroup& instead of separate row_group_index + row_ranges.
  • No storage format or protocol changes.

Documentation

No new features introduced. Internal refactoring only.

Generative AI tooling

Generated-by: Aone Copilot (Claude 4.7 Opus)

Copilot AI review requested due to automatic review settings June 3, 2026 08:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Refactors Parquet reading to unify row-group targeting (including page-level filtered ranges), centralize Parquet/Arrow exception handling, and tighten predicate filtering behavior.

Changes:

  • Introduces TargetRowGroup and propagates it through readers/tests to carry row-group index + page-filter row ranges.
  • Moves PAIMON_PARQUET_CATCH_AND_RETURN_STATUS into a shared header and updates callers.
  • Adds conservative fallback in ColumnIndexFilter when comparison predicates have empty literals, with new tests.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/paimon/format/parquet/row_ranges.h Adds RowRanges move-ctor and introduces TargetRowGroup for carrying per-RG filtering info
src/paimon/format/parquet/parquet_format_defs.h Adds shared macro to convert exceptions to Status
src/paimon/format/parquet/parquet_file_batch_reader.h Switches read-range application to ApplyReadRanges
src/paimon/format/parquet/parquet_file_batch_reader.cpp Refactors schema setup and read-range application around TargetRowGroup
src/paimon/format/parquet/page_filtered_row_group_reader.h Updates APIs to accept TargetRowGroup and factors helpers into private methods
src/paimon/format/parquet/page_filtered_row_group_reader.cpp Implements new helpers and updates page-filtered read logic to use TargetRowGroup
src/paimon/format/parquet/file_reader_wrapper.h Replaces row-group index sets with TargetRowGroup list and adds ApplyReadRanges API
src/paimon/format/parquet/file_reader_wrapper.cpp Refactors reading loop into page-filtered vs fully-matched paths, adds prebuffer range collection, implements ApplyReadRanges
src/paimon/format/parquet/page_filtered_row_group_reader_test.cpp Updates tests to pass TargetRowGroup
src/paimon/format/parquet/file_reader_wrapper_test.cpp Updates tests for new PrepareForReading* signatures and new ApplyReadRanges behavior
src/paimon/format/parquet/column_index_filter.cpp Adds conservative fallback when literals are empty for non-null-check predicates
src/paimon/format/parquet/column_index_filter_test.cpp Adds tests covering empty-literals behavior for comparison and IN predicates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/paimon/format/parquet/row_ranges.h
Comment thread src/paimon/format/parquet/parquet_format_defs.h
Comment thread src/paimon/format/parquet/file_reader_wrapper.h
Comment thread src/paimon/format/parquet/file_reader_wrapper.cpp
Comment thread src/paimon/format/parquet/file_reader_wrapper.cpp
Comment thread src/paimon/format/parquet/file_reader_wrapper.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants