Jefffrey commented on code in PR #10229:
URL: https://github.com/apache/arrow-rs/pull/10229#discussion_r3488031755


##########
arrow-row/src/variable.rs:
##########
@@ -69,6 +71,12 @@ pub(crate) fn non_null_padded_length(len: usize) -> usize {
     }
 }
 
+pub(crate) fn decode_nulls_sentinel(rows: &[&[u8]], options: SortOptions) -> 
Option<NullBuffer> {

Review Comment:
   Similar to the one in `fixed.rs` but compares using `null_sentinel()`



##########
arrow-row/src/fixed.rs:
##########
@@ -402,61 +397,19 @@ pub fn decode_bool(rows: &mut [&[u8]], options: 
SortOptions) -> BooleanArray {
         values.push(values_packed);
     }
 
-    let builder = ArrayDataBuilder::new(DataType::Boolean)
-        .len(rows.len())
-        .null_count(null_count)
-        .add_buffer(values.into())
-        .null_bit_buffer(Some(nulls.into()));
+    let nulls = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, len));
+    let nulls = (nulls.null_count() > 0).then_some(nulls);
 
-    // SAFETY:
-    // Buffers are the correct length
-    unsafe { BooleanArray::from(builder.build_unchecked()) }
+    BooleanArray::new(BooleanBuffer::new(values.into(), 0, len), nulls)
 }
 
 /// Decodes a single byte from each row, interpreting `0x01` as a valid value
-/// and all other values as a null
-///
-/// Returns the null count and null buffer
-pub fn decode_nulls(rows: &[&[u8]]) -> (usize, Buffer) {
-    let mut null_count = 0;
-    let buffer = MutableBuffer::collect_bool(rows.len(), |idx| {
-        let valid = rows[idx][0] == 1;
-        null_count += !valid as usize;
-        valid
-    })
-    .into();
-    (null_count, buffer)
-}
-
-/// Decodes a `ArrayData` from rows based on the provided 
`FixedLengthEncoding` `T`
-///
-/// # Safety
-///
-/// `data_type` must be appropriate native type for `T`
-unsafe fn decode_fixed<T: FixedLengthEncoding + ArrowNativeType>(

Review Comment:
   This has been inlined into `decode_primitive`



##########
arrow-row/src/fixed.rs:
##########
@@ -402,61 +397,19 @@ pub fn decode_bool(rows: &mut [&[u8]], options: 
SortOptions) -> BooleanArray {
         values.push(values_packed);
     }
 
-    let builder = ArrayDataBuilder::new(DataType::Boolean)
-        .len(rows.len())
-        .null_count(null_count)
-        .add_buffer(values.into())
-        .null_bit_buffer(Some(nulls.into()));
+    let nulls = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, len));
+    let nulls = (nulls.null_count() > 0).then_some(nulls);
 
-    // SAFETY:
-    // Buffers are the correct length
-    unsafe { BooleanArray::from(builder.build_unchecked()) }
+    BooleanArray::new(BooleanBuffer::new(values.into(), 0, len), nulls)
 }
 
 /// Decodes a single byte from each row, interpreting `0x01` as a valid value
-/// and all other values as a null
-///
-/// Returns the null count and null buffer
-pub fn decode_nulls(rows: &[&[u8]]) -> (usize, Buffer) {

Review Comment:
   Instead of returning a separate null count & null buffer (as `Buffer`), just 
return `Option<NullBuffer>` where `None` is if the resulting null buffer has 0 
nulls



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