Deprecate NullBuilder capacity, as it behaves in a surprising way #5721
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #5711.
Rationale for this change
It seems everyone at #5711 has so far agreed that having
NullBuilder::with_capacity()
set the builder length is surprising / feels like a bug, and that the notion of capacity makes no sense for this builder in general. Therefore, this PR is deprecating the notion ofNullBuilder
capacity where possible, and ignoring capacity inNullBuilder::with_capacity()
andNullArray::builder()
to remove the buggy behavior.What changes are included in this PR?
NullBuilder::with_capacity()
andNullBuilder::capacity()
are deprecated.NullBuilder::with_capacity()
andNullArray::builder()
are switched to the more sensible behavior of ignoring input capacity instead of setting a nonzero initial builder length.Are there any user-facing changes?
Both changes listed above are user-facing.
Although it does affect API semantics, I don't think making
NullBuilder::with_capacity()
andNullArray::builder()
ignore their argument should be considered a breaking change, beacause the current behavior of setting the length was considered to be a bug in #5711 discussion.