Skip to content

GH-50260: [C++] Add ComputeLogicalNullCount to ChunkedArray#50261

Open
goel-skd wants to merge 1 commit into
apache:mainfrom
goel-skd:gh-50260-chunkedarray-logical-null-count
Open

GH-50260: [C++] Add ComputeLogicalNullCount to ChunkedArray#50261
goel-skd wants to merge 1 commit into
apache:mainfrom
goel-skd:gh-50260-chunkedarray-logical-null-count

Conversation

@goel-skd

@goel-skd goel-skd commented Jun 26, 2026

Copy link
Copy Markdown

Rationale for this change

Array and ArrayData expose ComputeLogicalNullCount(), which counts logical nulls for types that carry them without a validity bitmap (e.g. unions and run-end encoded arrays).
ChunkedArray only exposed null_count(), which does not account for those logical nulls, so callers had to hand-roll a loop over the chunks. This PR closes that gap.

What changes are included in this PR?

Add ChunkedArray::ComputeLogicalNullCount(), returning the sum of Array::ComputeLogicalNullCount() over the chunks. As with the Arraylevel method, the value is recomputed on each call rather than cached.

Are these changes tested?

Yes. A new TestChunkedArray.ComputeLogicalNullCount test covers three cases:

  • a type with a validity bitmap (result matches null_count()),

  • an empty chunked array, and,

  • a run-end encoded chunked array (where null_count() is 0 but the logical null count is not).

    Are there any user-facing changes?

Yes, this adds a new public method, ChunkedArray::ComputeLogicalNullCount(). The change is purely additive; no existing APIs are modified.

ChunkedArray exposed null_count() but had no equivalent of
Array::ComputeLogicalNullCount, forcing callers to hand-roll a loop over
chunks to account for logical nulls in types without a validity bitmap
(unions, run-end encoded arrays).

Add ChunkedArray::ComputeLogicalNullCount() that returns the sum of the
per-chunk logical null counts. Like the Array-level method, it is
recomputed on every call rather than cached. Covered by a new
TestChunkedArray test exercising a validity-bitmap type, an empty
chunked array, and a run-end encoded chunked array.
@goel-skd goel-skd requested a review from pitrou as a code owner June 26, 2026 02:33
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50260 has been automatically assigned in GitHub to PR creator.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant