Skip to content

feat: Add RowSelection::total_row_count - #10704

Merged
alamb merged 3 commits into
apache:mainfrom
haohuaijin:row-selection-total-row-count
Aug 19, 2026
Merged

feat: Add RowSelection::total_row_count#10704
alamb merged 3 commits into
apache:mainfrom
haohuaijin:row-selection-total-row-count

Conversation

@haohuaijin

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

RowSelection exposes row_count() (selected rows) and skipped_row_count() (skipped rows), but no way to get the total number of rows a selection spans. Callers that need the total (e.g. to validate a selection against a row group's row count, as #10702 does) must call both methods, which iterates a selector-backed selection twice and performs two popcounts on a mask-backed selection just to have them cancel out.

What changes are included in this PR?

Adds RowSelection::total_row_count(), which computes the total in a single pass:

  • selector-backed: one sum over the selectors
  • mask-backed: mask.len(), O(1) with no popcount

Are these changes tested?

Yes, a unit test covers both backings plus the empty selection.

Are there any user-facing changes?

New public method RowSelection::total_row_count(). No changes to existing APIs.

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Aug 16, 2026
@haohuaijin haohuaijin changed the title parquet: Add RowSelection::total_row_count feat: Add RowSelection::total_row_count Aug 16, 2026

@Rich-T-kid Rich-T-kid 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.

makes sense to me

@alamb alamb 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.

Thank you @haohuaijin and @Rich-T-kid -- this makes sense to me

I also took the liberty of updating some tests to use the new method to add some additional test coverage

@alamb alamb changed the title feat: Add RowSelection::total_row_count feat: Add RowSelection::total_row_count Aug 18, 2026
@haohuaijin

Copy link
Copy Markdown
Contributor Author

Thanks @Rich-T-kid @alamb

@alamb
alamb merged commit 4b3f619 into apache:main Aug 19, 2026
18 checks passed
@haohuaijin
haohuaijin deleted the row-selection-total-row-count branch August 19, 2026 12:16
MassivePizza pushed a commit to massive-com/arrow-rs that referenced this pull request Aug 19, 2026
# Which issue does this PR close?

- Part of apache#10624.

# Rationale for this change

`RowSelection` exposes `row_count()` (selected rows) and
`skipped_row_count()` (skipped rows), but no way to get the total number
of rows a selection spans. Callers that need the total (e.g. to validate
a selection against a row group's row count, as apache#10702 does) must call
both methods, which iterates a selector-backed selection twice and
performs two popcounts on a mask-backed selection just to have them
cancel out.

# What changes are included in this PR?

Adds `RowSelection::total_row_count()`, which computes the total in a
single pass:

- selector-backed: one sum over the selectors
- mask-backed: `mask.len()`, O(1) with no popcount

# Are these changes tested?

Yes, a unit test covers both backings plus the empty selection.

# Are there any user-facing changes?

New public method `RowSelection::total_row_count()`. No changes to
existing APIs.

---------

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants