nevi-me commented on a change in pull request #826:
URL: https://github.com/apache/arrow-rs/pull/826#discussion_r727789375



##########
File path: arrow/src/json/reader.rs
##########
@@ -1048,31 +1048,28 @@ impl Decoder {
             }
             DataType::Struct(fields) => {
                 // extract list values, with non-lists converted to Value::Null
-                let array_item_count = rows
-                    .iter()
-                    .map(|row| match row {
-                        Value::Array(values) => values.len(),
-                        _ => 1,
-                    })
-                    .sum();
+                let array_item_count = cur_offset.to_usize().unwrap();
                 let num_bytes = bit_util::ceil(array_item_count, 8);
                 let mut null_buffer = 
MutableBuffer::from_len_zeroed(num_bytes);
                 let mut struct_index = 0;
                 let rows: Vec<Value> = rows
                     .iter()
-                    .flat_map(|row| {
-                        if let Value::Array(values) = row {
-                            values.iter().for_each(|_| {
-                                bit_util::set_bit(
-                                    null_buffer.as_slice_mut(),
-                                    struct_index,
-                                );
+                    .flat_map(|row| match row {
+                        Value::Array(values) if !values.is_empty() => {
+                            values.iter().for_each(|value| {
+                                if let Value::Null = value {

Review comment:
       `is_null()` does more, but the compiler can optimise it 
https://godbolt.org/z/76x4316Y9
   
   So I'll change to that, thanks @houqp 




-- 
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-unsubscr...@arrow.apache.org

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


Reply via email to