You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "Virgiel (via GitHub)" <gi...@apache.org> on 2023/06/22 13:23:40 UTC

[GitHub] [arrow-rs] Virgiel opened a new issue, #4444: Reuse schema when importing from FFI

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: github-unsubscribe@arrow.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on issue #4444: Reuse schema when importing from FFI

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #4444:
URL: https://github.com/apache/arrow-rs/issues/4444#issuecomment-1614543852

   `label_issue.py` automatically added labels {'arrow'} from #4447


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold closed issue #4444: Reuse schema when importing from FFI

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold closed issue #4444: Reuse schema when importing from FFI
URL: https://github.com/apache/arrow-rs/issues/4444


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] tustvold commented on issue #4444: Reuse schema when importing from FFI

Posted by "tustvold (via GitHub)" <gi...@apache.org>.
tustvold commented on issue #4444:
URL: https://github.com/apache/arrow-rs/issues/4444#issuecomment-1604220990

   I like the from_ffi proposal, the current API has definitely evolved naturally and would benefit from a rethink


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org