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


##########
arrow-select/src/coalesce.rs:
##########
@@ -47,6 +50,54 @@ use generic::GenericInProgressArray;
 use list::InProgressListArray;
 use primitive::InProgressPrimitiveArray;
 
+/// Appends the validity bits selected by `indices` to `nulls`.
+///
+/// # Safety
+///
+/// `indices` must not contain nulls, and every value must be less than
+/// `source_nulls.len()`.
+pub(crate) unsafe fn append_gathered_nulls(
+    nulls: &mut NullBufferBuilder,
+    source_nulls: &NullBuffer,
+    indices: &UInt32Array,
+) {
+    debug_assert!(
+        indices
+            .values()
+            .iter()
+            .all(|&idx| (idx as usize) < source_nulls.len()),
+        "append_gathered_nulls received out-of-bounds index",
+    );
+    if source_nulls.null_count() == 0 {
+        nulls.append_n_non_nulls(indices.len());
+        return;
+    }
+    let gathered = take_bits::<UInt32Type, false>(source_nulls.inner(), 
indices);
+    nulls.append_buffer(&NullBuffer::new(gathered));
+}
+
+pub(crate) fn validate_indices_bounds(

Review Comment:
   agreed 👍  



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