Repository navigation
fix: Size decimal string buffers by the value rather than the type's precision (#546) - #548
Merged
CurtHagenlocher merged 1 commit intoDec 5, 2026
Conversation
…precision (apache#546) ### What's changed? Formatting a decimal as a string (`GetString`, and so `ToString` on the decimal arrays) and parsing one from a string sized their buffers by the type's precision and scale. On .NET Core the buffers were on the stack, so a type with a very large precision or scale could exhaust it. - The buffers are now sized by the digits the value can have. A value of a given byte width has at most 2.5 digits per byte, plus any zeros the scale adds. - Buffers of up to 256 chars stay on the stack; larger ones go on the heap. Sizes are computed so they can't overflow. - On .NET Framework the buffers were already on the heap, but were sized by the precision; they are now sized the same way. The precision is still used to reject values with too many digits, and results are unchanged. ### Testing New tests in `DecimalUtilityTests` format and parse values with a precision of up to `int.MaxValue` and a scale of 1,000,000, at byte widths 4, 8, 16 and 32, and format the largest and smallest value of each width with a very large precision. All of `Apache.Arrow.Tests` passes on net8.0, net462 and net472. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_012dFdcrBz22tRjiyNwBd7VB --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 266791f)
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.
Brings #546 to maint-23.x. It applied cleanly.