You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add validated constructors for UnionFields (#8891)
- related to #3982
# Rationale for this change
This PR introduces `UnionFields::try_new` and `UnionFields::from_fields`
as replacements for the "unsafe" `UnionFields::new` constructor, which
is now deprecated
Previously, `UnionFields` could be constructed with invalid invariants
including negative type ids, duplicate type ids, or duplicate fields.
Since `UnionArrays` index by type id, negative values cause panics at
runtimes and duplicates break comparisons.
`UnionFields::try_new` validates that type ids are non-negative, unique,
under 128, and that fields are unique, returning an error if any
constraint is violated.
`UnionFields::from_fields` is a convenience constructor that
auto-assigns sequential type ids starting from 0. (Will panic if it
exceeds 128 elements)
# Note about reviewing
I broke it up into smaller commits. The last commit updates all call
sites across the different kernels
---------
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
0 commit comments