tustvold opened a new issue, #1811:
URL: https://github.com/apache/arrow-rs/issues/1811

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   Currently the Array implementations make use of `RawPtrBox` to reference 
data on their attached ArrayData. Not only is this construction deeply unsafe, 
but requires further unsafe pointer manipulation to use.
   
   **Describe the solution you'd like**
   
   I would like for arrays to store strongly typed slices, instead of strongly 
typed pointers. This necessarily implies a self-referential trait, fortunately 
[ouroboros](https://crates.io/crates/ouroboros) provides a safe interface that 
handles this complexity for you. The hardest part is actually spelling the 
crates' name...
   
   ```
   #[self_referencing]
   pub struct PrimitiveArray<T: ArrowPrimitiveType> {
       data: ArrayData,
       #[borrows(data)]
       values: &'this [T::Native]
   }
   ```
   
   This would eliminate a lot of unsafe, without requiring any breaking changes.
   
   **Describe alternatives you've considered**
   
   We could not do this, this might just be a way to reduce the amount of 
unsafe in arrow-rs without requiring any breaking changes.
   
   **Related Context**
   
   Somewhat related to https://github.com/apache/arrow-rs/issues/1799 which 
introduces stronger typing within ArrayData itself.
   
   We used ouroboros for a while in IOx to handle flatbuffers, and it did the 
job.  We have since removed flatbuffers in favor of a columnar protobuf 
representation, but that was more a reflection on flatbuffers than ouroboros.
   
   Thoughts @alamb @jhorstmann @jorgecarleitao @HaoYang670 ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to