Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale for this change
This is the first step towards #45722 (adding
UnsafeAppendmethods toStructBuilder). In #47522, reviewers pointed out that a struct null also needs an "empty value" added to each child builder, and there was no unsafe way to do that. pitrou suggested starting with a separate PR that addsUnsafeAppendEmptyValue()andUnsafeAppendEmptyValues()to all builders, so that's what this PR does.What changes are included in this PR?
ArrayBuildergets two new virtual methods,UnsafeAppendEmptyValue()andUnsafeAppendEmptyValues(int64_t). They do the same thing asAppendEmptyValue(s)but skip the capacity check, so the caller must callReserve()first.AppendEmptyValue(s)methods now just callReserve()and then the unsafe version, as pitrou suggested in GH-45722: [C++] Add UnsafeAppend methods to StructBuilder #47522.ArrayBuilderthat calls the safe method.Are these changes tested?
Yes. I added
TestArray.TestUnsafeAppendEmptyValue, which goes through the types inTestArrayUtilitiesAgainstTheseTypes()plus a nested struct. For each type it builds one array with the safe methods and one with reserve plus the unsafe methods, then checks that they're equal. Allarrow-array-testtests pass locally (Ubuntu 24.04, GCC 13, Debug build).Are there any user-facing changes?
Yes, two new public methods on
ArrayBuilderand its subclasses. Existing code keeps working.Questions for reviewers
ArrayBuilderoutside Arrow don't break. Would you rather have them pure virtual?AI usage
I used an AI coding assistant (Kiro) to explore the builder code and to draft the implementation and the test. I reviewed every change, checked the design decisions above, built it locally, and ran the tests. I also broke the struct change on purpose to confirm the test catches it.