Skip to content

feat(arrow-array): add GenericByteViewArray::total_bytes_len - #9641

Merged
alamb merged 1 commit into
apache:mainfrom
hcrosse:feat/total-bytes-len-byte-view-array
Apr 6, 2026
Merged

feat(arrow-array): add GenericByteViewArray::total_bytes_len#9641
alamb merged 1 commit into
apache:mainfrom
hcrosse:feat/total-bytes-len-byte-view-array

Conversation

@hcrosse

@hcrosse hcrosse commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

total_buffer_bytes_used() only counts non-inlined strings (> 12 bytes), so it returns 0 for arrays of short strings. This makes it unsuitable as a capacity hint when pre-allocating output buffers (e.g. in DataFusion's concat()/concat_ws()).

What changes are included in this PR?

Adds total_bytes_len() to GenericByteViewArray, which sums byte lengths of all non-null values including inlined strings.

Are there any user-facing changes?

New public method on GenericByteViewArray (and by extension StringViewArray / BinaryViewArray).

Sums byte lengths of all non-null values, including inlined strings that
total_buffer_bytes_used() skips. Closes apache#9435
@github-actions github-actions Bot added the arrow Changes to the arrow crate label Apr 1, 2026

@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 @hcrosse

This is great

FYI @neilconway

@neilconway

Copy link
Copy Markdown
Contributor

🎉 Awesome, thank you @hcrosse !

@alamb
alamb merged commit c884f1d into apache:main Apr 6, 2026
27 checks passed
@alamb

alamb commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Thanks again @hcrosse and @neilconway

Rich-T-kid pushed a commit to Rich-T-kid/arrow-rs that referenced this pull request Jun 2, 2026
…9641)

# Which issue does this PR close?

- Closes apache#9435

# Rationale for this change

`total_buffer_bytes_used()` only counts non-inlined strings (> 12
bytes), so it returns 0 for arrays of short strings. This makes it
unsuitable as a capacity hint when pre-allocating output buffers (e.g.
in DataFusion's `concat()`/`concat_ws()`).

# What changes are included in this PR?

Adds `total_bytes_len()` to `GenericByteViewArray`, which sums byte
lengths of all non-null values including inlined strings.

# Are there any user-facing changes?

New public method on `GenericByteViewArray` (and by extension
`StringViewArray` / `BinaryViewArray`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GenericByteViewArray: support finding total length of all strings

3 participants