Skip to content

MINOR: [C++][Compute][Parquet] Avoid redundant metadata copies - #55647

Open
Sumdiboii wants to merge 1 commit into
apache:mainfrom
Sumdiboii:perf/cpp-avoid-unnecessary-copies
Open

Sumdiboii wants to merge 1 commit into
apache:mainfrom
Sumdiboii:perf/cpp-avoid-unnecessary-copies

Conversation

@Sumdiboii

Copy link
Copy Markdown
Contributor

Rationale for this change

I opened a small cleanup PR yesterday while getting familiar with the Arrow codebase. While continuing to read through the code, I noticed that some of the same patterns addressed in that PR were also present in other related code paths.

The earlier PR fixed these patterns in one place, but similar cases remained elsewhere. This PR applies the same small improvements to those remaining occurrences.

I also found that the Parquet metadata builder copied the complete row-group metadata vector when finalizing file metadata. Since the builder is finalizing its state at that point, the row-group metadata can be moved into the final Thrift structure instead. This avoids an unnecessary allocation and copy, particularly for files with many row groups.

What changes are included in this PR?

  • Bind chunk and container metadata with const auto& when the values are only read, avoiding unnecessary copies.
  • Move row-group metadata into the finalized Parquet Thrift structure instead of copying the complete vector.
  • Replace size() == 0 and size() > 0 checks with empty() and !empty(). I used the same style in my previous PR and found more places where it made the intent clearer while reading through the codebase.
  • Keep the changes limited to small, behavior-preserving C++ cleanups.

Are these changes tested?

No runtime tests were run locally.

I ran git diff --check successfully. A configured C++ build directory was not available in the checkout, so I was not able to run the focused Arrow or Parquet tests locally.

Are there any user-facing changes?

No. There are no public API or serialized-format changes. The changes only avoid unnecessary copies and make existing container checks more direct.

Was AI used for this PR?

AI was used to help search through the codebase and inspect the relevant code paths. The changes and reasoning were reviewed before preparing this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

Keep chunk and container metadata bound by reference on read-only paths, and move row-group metadata into the finalized Parquet Thrift structure instead of copying it. Replace the related empty-container checks with empty() for clarity.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 17, 2026 09:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain, and the changes are limited to behavior-preserving C++ cleanups and metadata move optimizations.

No open issues 🎉

Review effort: Lite

@Sumdiboii

Copy link
Copy Markdown
Contributor Author

The 4 failing tests are unrelated to the changes I made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants