Rich-T-kid commented on code in PR #11912:
URL: https://github.com/apache/arrow-rs/pull/11912#discussion_r4404080713


##########
arrow-row/src/fixed.rs:
##########
@@ -449,19 +457,25 @@ pub fn decode_fixed_size_binary(
     rows: &mut [&[u8]],
     size: i32,
     options: SortOptions,
-) -> FixedSizeBinaryArray {
+) -> Result<FixedSizeBinaryArray, ArrowError> {

Review Comment:
   here as well



##########
arrow-row/src/fixed.rs:
##########
@@ -356,16 +356,19 @@ fn split_off<'a>(src: &mut &'a [u8], len: usize) -> &'a 
[u8] {
 }
 
 /// Decodes a `BooleanArray` from rows
-pub fn decode_bool(rows: &mut [&[u8]], options: SortOptions) -> BooleanArray {
+pub fn decode_bool(rows: &mut [&[u8]], options: SortOptions) -> 
Result<BooleanArray, ArrowError> {

Review Comment:
   we should avoid this breaking API change



##########
arrow-row/src/fixed.rs:
##########
@@ -402,30 +405,35 @@ pub fn decode_bool(rows: &mut [&[u8]], options: 
SortOptions) -> BooleanArray {
     let nulls = NullBuffer::new(BooleanBuffer::new(nulls.into(), 0, len));
     let nulls = (nulls.null_count() > 0).then_some(nulls);
 
-    BooleanArray::new(BooleanBuffer::new(values.into(), 0, len), nulls)
+    Ok(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. Optionally returns `None` if there are no
 /// null values.
-pub fn decode_nulls(rows: &[&[u8]]) -> Option<NullBuffer> {
-    let nulls = BooleanBuffer::collect_bool(rows.len(), |idx| rows[idx][0] == 
1);
+pub fn decode_nulls(rows: &[&[u8]]) -> Result<Option<NullBuffer>, ArrowError> {
+    let nulls = MutableBuffer::try_collect_bool(rows.len(), |idx| rows[idx][0] 
== 1)
+        .map_err(|e| ArrowError::MemoryError(e.to_string()))?;
+    let nulls = BooleanBuffer::new(nulls.into(), 0, rows.len());
     let nulls = NullBuffer::new(nulls);
-    (nulls.null_count() > 0).then_some(nulls)
+    Ok((nulls.null_count() > 0).then_some(nulls))
 }
 
 /// Decodes a `PrimitiveArray` from rows
 pub fn decode_primitive<T: ArrowPrimitiveType>(

Review Comment:
   and here



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