jayzhan211 commented on code in PR #26485:
URL: https://github.com/apache/datafusion/pull/26485#discussion_r4313616758
##########
datafusion/functions-aggregate/src/bit_and_or_xor.rs:
##########
@@ -434,6 +434,8 @@ where
struct BitXorAccumulator<T: ArrowNumericType> {
value: Option<T::Native>,
Review Comment:
nit: now that `non_null_count` decides NULL-ness, the `Option` on `value` is
redundant. A plain native value starting at 0 (the XOR identity) drops both
`get_or_insert_with` calls and shortens `evaluate`. I checked that this
compiles and the existing tests pass:
```diff
- value: Option<T::Native>,
+ value: T::Native,
```
```rs
fn update_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
if let Some(x) =
arrow::compute::bit_xor(values[0].as_primitive::<T>()) {
self.value = self.value ^ x;
}
self.non_null_count += values[0].len() - values[0].null_count();
Ok(())
}
fn evaluate(&mut self) -> Result<ScalarValue> {
let value = (self.non_null_count > 0).then_some(self.value);
ScalarValue::new_primitive::<T>(value, &T::DATA_TYPE)
}
```
`retract_batch` would look the same as `update_batch`, except that it uses
`-=` on the count, and `Default` would use `T::Native::usize_as(0)`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]