sunchao commented on code in PR #1960:
URL: https://github.com/apache/arrow-rs/pull/1960#discussion_r909242389


##########
arrow/src/ffi.rs:
##########
@@ -450,7 +450,17 @@ impl FFI_ArrowArray {
         let buffers = iter::once(data.null_buffer().cloned())
             .chain(data.buffers().iter().map(|b| Some(b.clone())))
             .collect::<Vec<_>>();
-        let n_buffers = buffers.len() as i64;

Review Comment:
   hmm why `n_buffers` would be 1 in the case of `NullArray`? in Rust the 
`null_buffer` is `None` right? is it different in Java?



##########
arrow/src/ffi.rs:
##########
@@ -450,7 +450,17 @@ impl FFI_ArrowArray {
         let buffers = iter::once(data.null_buffer().cloned())
             .chain(data.buffers().iter().map(|b| Some(b.clone())))
             .collect::<Vec<_>>();
-        let n_buffers = buffers.len() as i64;
+        let data_layout = layout(data.data_type());
+        // `n_buffers` is the number of buffers by the spec.
+        let n_buffers = {
+            data_layout.buffers.len() + {
+                if data_layout.can_contain_null_mask {
+                    1

Review Comment:
   maybe add a comment explaining why we need to add 1 here (it is for the null 
buffer right?)



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