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

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   The reason the Arrow C data interface has a separate Schema and Array struct 
is to allow [reuse of a single 
schema](https://arrow.apache.org/docs/format/CDataInterface.html#why-two-distinct-structures)
 with multiple array, but currently the arrow-rs API doesn't allow this because 
`ArrowArray::new` consumes the schema.
   
   **Describe the solution you'd like**
   
   In a fork, I have added a new function to swap the inner array :
   ```rs
   impl ArrowArray {
       /// Swap the internal FFI array with a new one
       pub fn swap(&mut self, array: FFI_ArrowArray) {
           self.array = Arc::new(array);
       }
   }
   
   ```
   
   This is compatible with existing tests.
   
   **Describe alternatives you've considered**
   
   We could change the constructor :
   
   ```rs
   impl ArrowArray {
       /// Creates a new [`ArrowArray`] from the provided array and schema
       pub fn new(array: FFI_ArrowArray, schema: Arc<FFI_ArrowSchema>) -> Self {
           Self {
               array: Arc::new(array),
               schema,
           }
       }
   }
   
   ```
   
   I also think it's possible to simplify all the `ArrowArray`, 
`ArrowArrayChild` and `ArrowArrayRef` logic and hide the implementation details 
by using just two functions:
   
   ```rs
   pub fn to_ffi(data: ArrayData) -> Result<(FFI_ArrowArray, FFI_ArrowSchema)> {
       todo!()
   }
   
   pub fn from_ffi(array: FFI_ArrowArray, schema: &FFI_ArrowSchema) -> 
Result<ArrayData> {
       todo!()
   }
   
   ```
   
   I can explore this more disruptive solution if you are interested.
   


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