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
Introduce a new Rust type for what ArrayTypes "really are": FlatArray.
As an unsized type, it will primarily be used as `&FlatArray<'_, T>` or
similar in actual extension code. The long-term plan is for FlatArray to
phase out `pgrx::datum::Array<'_, T>` entirely, as it has several
advantages over its predecessor:
- It uses `Element`, a subset of `BorrowDatum`, to power its simplicity
in iteration, making it more easily verifiable and maintainable.
- It is the unsized type itself, allowing composing it with various
Rusty pointer types like `&`, `&mut`, or `PBox`.
- It is no longer endangered by performance cliffs or hidden allocations
depending on the type of `T`.
- Because of these previous traits, it is possible to soundly and safely
allocate a fresh `FlatArray`, mutate it, and return that one allocation,
instead of allocating an intermediate Vec in Rust memory to mutate!
It also has an associated cost in that it no longer supports any `T`
that requires complex unboxing of items like `datum::Array<'a, String>`.
You must instead use `array.iter().map(closure)` to accomplish that.
This itself summarizes the difference: `datum::Array` is effectively an
iteration protocol, but `array::FlatArray` is an actual data structure.
This addresses the implied feature request in, and thus supercedes,
pgcentralfoundation#2086.
note: if you're trying to build a new `PBox<'_, FlatArray<'_, FlatArray<'_, i32>>>`, consider using `PBox::<'mcx, T>::from_raw_in` which returns `PBox<'_, _>`
0 commit comments