You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2023/01/07 20:00:19 UTC

[GitHub] [arrow-datafusion] ozankabak commented on a diff in pull request #4846: Implement retract_batch for AvgAccumulator

ozankabak commented on code in PR #4846:
URL: https://github.com/apache/arrow-datafusion/pull/4846#discussion_r1064041043


##########
datafusion/physical-expr/src/aggregate/average.rs:
##########
@@ -154,6 +159,14 @@ impl Accumulator for AvgAccumulator {
         Ok(())
     }
 
+    fn retract_batch(&mut self, values: &[ArrayRef]) -> Result<()> {
+        let values = &values[0];
+        self.count -= (values.len() - values.data().null_count()) as u64;
+        let delta = sum_batch(values, &self.sum.get_datatype())?;
+        self.sum = self.sum.sub(&delta)?;

Review Comment:
   I like giving a name to the change (i.e. `delta`). I suggest doing the same in `update_batch`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org