Skip to content

Expose builder buffer capacity accessors#10342

Merged
Jefffrey merged 1 commit into
apache:mainfrom
Weijun-H:builder-capacity-accessors
Jul 17, 2026
Merged

Expose builder buffer capacity accessors#10342
Jefffrey merged 1 commit into
apache:mainfrom
Weijun-H:builder-capacity-accessors

Conversation

@Weijun-H

Copy link
Copy Markdown
Member

Which issue does this PR close?

Rationale for this change

Downstream memory accounting sometimes needs to measure the allocated capacity currently retained by Arrow array builders, including allocation slack after buffer growth. Existing slice accessors expose initialized data, but not the underlying values, offsets, or validity-buffer capacity.

What changes are included in this PR?

This adds read-only capacity accessors for existing builder internals:

  • GenericByteBuilder::{values_capacity, offsets_capacity, validity_capacity}
  • GenericListBuilder::{offsets_capacity, validity_capacity}
  • PrimitiveBuilder::validity_capacity
  • StructBuilder::validity_capacity

The methods only read existing builder state and do not change append, reserve, finish, or resize behavior.

Are these changes tested?

No behavior-specific tests are added because these methods only expose existing capacity fields through read-only forwarding accessors. Existing arrow-array builder tests were run unchanged, and the new public API is compile-checked by the crate.

Validated with:

  • cargo fmt --all -- --check
  • cargo test -p arrow-array builder --lib
  • cargo test -p arrow-array --lib
  • cargo +1.96.0 clippy -p arrow-array --all-targets --no-deps -- -D warnings

Are there any user-facing changes?

Yes. This adds public read-only capacity accessors on Arrow array builders.

@github-actions github-actions Bot added the arrow Changes to the arrow crate label Jul 14, 2026
@Weijun-H
Weijun-H marked this pull request as ready for review July 14, 2026 14:30

@rluvaton rluvaton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

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

nice!

@Jefffrey
Jefffrey merged commit 433e061 into apache:main Jul 17, 2026
30 checks passed
@Jefffrey

Copy link
Copy Markdown
Contributor

thanks @Weijun-H, @rluvaton & @Rich-T-kid

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.

Expose builder buffer capacity accessors

5 participants