ritchie46 commented on issue #1176:
URL: https://github.com/apache/arrow-rs/issues/1176#issuecomment-1448350221

   Can we take `PrimitiveArray` as an example?
   
   This currently is a small wrapper around a typed `Buffer<T>` and an optional 
bitmap `Option<Bitmap>`.
   ```rust
   pub struct PrimitiveArray<T: NativeType> {
       data_type: DataType,
       values: Buffer<T>,
       validity: Option<Bitmap>,
   }
   ```
   
   As I understand you want to convert it to
   
   ```rust
   struct PrimitiveArray<T: NativeType> {
     array_data: ArrayData
     phantom_data: Phantom<T>
   }
   
   enum ArrrayData {
      Primitive{..},
      Utf8{..},
      ...
   }
   ```
   
   This would cost an extra check upon random access of the array as the 
variant of the `ArrayData` needs to be unpacked, or there needs to be used 
extra unsafe and hope the compiler is able to compile away those branches that 
will not be hit. Besides that to me it feels the wrong way around to go from 
known type with an untyped buffer inside. The other way around makes much more 
sense to me. 


-- 
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