Commit 1f0615a
authored
Fix ArrowBytesViewMap retained capacity accounting (#24257)
## Which issue does this PR close?
* Part of #23393
## Rationale for this change
`ArrowBytesViewMap::size()` can underreport memory retained by the map.
It previously omitted the initial allocation of the hash table, counted
`views` by length rather than capacity, counted completed buffers by
used length rather than retained capacity, and did not include the
backing allocation of the `completed` vector.
Because this value is used for memory accounting, it should reflect heap
allocations owned by the map while continuing to exclude `self` and
external input-array buffers.
## What changes are included in this PR?
* Initialize `map_size` from the hash table's initial allocated
capacity.
* Account for `views` and the in-progress buffer using their allocated
sizes.
* Include the allocation backing the `completed` vector.
* Account for each completed Arrow `Buffer` by retained capacity rather
than used length.
* Clarify that `size()` excludes both `self` and input-array buffers.
## Are these changes tested?
Yes. This PR adds:
* `test_size_counts_initial_hash_table_capacity`, which verifies that a
newly created map reports the initial hash table allocation.
* `test_size_counts_retained_buffer_capacities`, which verifies unused
`views` capacity, `completed` vector storage, retained completed-buffer
capacity, and that re-inserting duplicate values does not increase the
reported size.
## Are there any user-facing changes?
No public API or query-result behavior changes. This fixes internal
memory accounting so `ArrowBytesViewMap::size()` more accurately reports
allocations retained by the map.
## LLM-generated code disclosure
This PR includes LLM-generated code and comments. All LLM-generated
content has been manually reviewed.1 parent 84a8e6d commit 1f0615a
1 file changed
Lines changed: 80 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
158 | 161 | | |
159 | 162 | | |
160 | | - | |
161 | | - | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
469 | 472 | | |
470 | 473 | | |
471 | 474 | | |
472 | | - | |
| 475 | + | |
473 | 476 | | |
474 | | - | |
475 | | - | |
476 | | - | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
477 | 483 | | |
478 | 484 | | |
479 | 485 | | |
| |||
715 | 721 | | |
716 | 722 | | |
717 | 723 | | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
718 | 792 | | |
719 | 793 | | |
720 | 794 | | |
| |||
0 commit comments