viirya commented on code in PR #4447:
URL: https://github.com/apache/arrow-rs/pull/4447#discussion_r1242588995


##########
arrow/src/ffi.rs:
##########
@@ -222,41 +221,69 @@ unsafe fn create_buffer(
         .map(|ptr| Buffer::from_custom_allocation(ptr, len, owner))
 }
 
-pub trait ArrowArrayRef {
-    fn to_data(&self) -> Result<ArrayData> {
-        let data_type = self.data_type()?;
-        let len = self.array().len();
-        let offset = self.array().offset();
-        let null_count = self.array().null_count();
+/// Export to the C Data Interface
+pub fn to_ffi(data: &ArrayData) -> Result<(FFI_ArrowArray, FFI_ArrowSchema)> {
+    let array = FFI_ArrowArray::new(data);
+    let schema = FFI_ArrowSchema::try_from(data.data_type())?;
+    Ok((array, schema))
+}
+
+/// Import [ArrayData] from the C Data Interface
+///
+/// # Safety
+///
+/// This struct assumes that the incoming data agrees with the C data 
interface.
+pub fn from_ffi(array: FFI_ArrowArray, schema: &FFI_ArrowSchema) -> 
Result<ArrayData> {

Review Comment:
   Oh, I see. Cursor is just temporary struct which doesn't actually need to 
hold ownership like ArrowArray before.
   
   The refactoring just directly consumes FFI_ArrowArray and FFI_ArrowSchema 
into ArrayData.



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