perf: Add BulkNullStringArrayBuilder trait, use in repeat#21854
Open
neilconway wants to merge 2 commits intoapache:mainfrom
Open
perf: Add BulkNullStringArrayBuilder trait, use in repeat#21854neilconway wants to merge 2 commits intoapache:mainfrom
BulkNullStringArrayBuilder trait, use in repeat#21854neilconway wants to merge 2 commits intoapache:mainfrom
Conversation
Add a DataFusion-side trait that abstracts over the bulk-NULL string array builders (GenericStringArrayBuilder<O> and StringViewArrayBuilder), so that functions which dispatch over Utf8/LargeUtf8/Utf8View can adopt the new builders without giving up their single-bodied generic implementation. Convert `repeat` as the first call site. The output is null iff either input is null, so the per-row null match becomes a single NullBuffer::union over the input null buffers, evaluated once before the loop. Also mark the inherent append_value/append_placeholder methods on the new builders as #[inline]; without this, calls through the trait wrapper end up going through a non-inlined inherent and slow down small-output paths.
Weijun-H
reviewed
Apr 26, 2026
Weijun-H
approved these changes
Apr 26, 2026
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.
Add a DataFusion-side trait that abstracts over the bulk-NULL string array builders (GenericStringArrayBuilder and StringViewArrayBuilder), so that functions which dispatch over Utf8/LargeUtf8/Utf8View can adopt the new builders without giving up their single-bodied generic implementation.
Convert
repeatas the first call site. The output is null iff either input is null, so the per-row null match becomes a single NullBuffer::union over the input null buffers, evaluated once before the loop.Also mark the inherent append_value/append_placeholder methods on the new builders as #[inline]; without this, calls through the trait wrapper end up going through a non-inlined inherent and slow down small-output paths.
Which issue does this PR close?
repeatto use bulk-NULL string builder #21853.Rationale for this change
Optimize NULL handling in
repeatusing the bulk-NULL string builders that have recently been added. This requires addingBulkNullStringArrayBuilder, a trait that is similar in spirit to Arrow'sStringLikeArrayBuilder.Benchmarks:
What changes are included in this PR?
BulkNullStringArrayBuilderrepeatusingBulkNullStringArrayBuilderAre these changes tested?
Yes.
Are there any user-facing changes?
No.