Commit bc07966
fix: Add BaseVector::reusable() to recursively check vector reusability (facebookincubator#502)
Summary:
X-link: facebookincubator/velox#16471
This change adds a new static method BaseVector::reusable() that recursively checks if a vector and all its nested children are reusable (have use_count == 1).
The existing verifyVectorState() check in nimble FieldReader only verified the top-level vector's use_count, but complex types like ARRAY<ROW<BIGINT, REAL>> can have nested children that are shared across different parent vectors. When prepareForReuse() is called on a vector whose nested children are still referenced elsewhere, it corrupts those shared children by resetting them to size 0.
Adds BaseVector::reusable() which recursively checks use_count for ROW children, ARRAY elements, and MAP keys/values
Updates verifyVectorState() in nimble FieldReader to use the new recursive check
Adds unit tests for the new method
Reviewed By: Yuhta
Differential Revision: D937909721 parent 74f4fbc commit bc07966
2 files changed
+70
-67
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
61 | 64 | | |
62 | 65 | | |
63 | | - | |
| 66 | + | |
64 | 67 | | |
65 | 68 | | |
66 | 69 | | |
| |||
0 commit comments