alamb commented on code in PR #6396:
URL: https://github.com/apache/arrow-rs/pull/6396#discussion_r1761795643
##########
arrow-arith/src/arity.rs:
##########
@@ -435,6 +436,22 @@ where
}
}
+/// Computes the union of the nulls in two optional [`NullBuffer`] which
+/// is not shared with the input buffers.
+///
+/// The union of the nulls is the same as `NullBuffer::union(lhs, rhs)` but
+/// it does not increase the reference count of the null buffer.
+fn create_union_null_buffer(
+ lhs: Option<&NullBuffer>,
+ rhs: Option<&NullBuffer>,
+) -> Option<NullBuffer> {
+ match (lhs, rhs) {
+ (Some(lhs), Some(rhs)) => Some(NullBuffer::new(lhs.inner() &
rhs.inner())),
+ (Some(n), None) | (None, Some(n)) => Some(NullBuffer::new(n.inner() &
n.inner())),
Review Comment:
If I understand this correctly, it forces a copy of the null buffer's
contents?
##########
arrow-arith/src/arity.rs:
##########
@@ -313,7 +313,7 @@ where
))));
}
- let nulls = NullBuffer::union(a.logical_nulls().as_ref(),
b.logical_nulls().as_ref());
Review Comment:
Since we have `a` by value, perhaps we could add a
`PrimitiveArray::into_parts` that would deconstruct the `PrimitiveArray` into
its underlying `NullBuffer` and values 🤔
Following the model of
https://docs.rs/arrow/latest/arrow/array/struct.GenericByteArray.html#method.into_parts
That way we could directly use the `NullBuffer ` and avoid the copy in
`create_union_null_buffer`
--
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]