2010YOUY01 commented on code in PR #23324:
URL: https://github.com/apache/datafusion/pull/23324#discussion_r3542674569
##########
datafusion/physical-plan/src/aggregates/aggregate_hash_table/common.rs:
##########
@@ -171,6 +171,106 @@ impl<AggrMode> AggregateHashTable<AggrMode> {
})
}
+ /// Aggregates one input batch after selecting the mode-specific
accumulator
+ /// operation.
+ ///
+ /// Each aggregation mode chooses a different `aggregate_fn` according to
its
+ /// semantics. For example, partial aggregation takes raw inputs, and
update them
+ /// into stored partial states, so [`GroupsAccumulator::update_batch`] is
used.
+ pub(super) fn aggregate_batch_inner<F>(
+ &mut self,
+ batch: &RecordBatch,
+ mut aggregate_fn: F,
+ ) -> Result<()>
+ where
+ F: FnMut(
+ &mut HashAggregateAccumulator,
+ &EvaluatedAccumulatorArgs,
+ &[usize],
+ usize,
+ ) -> Result<()>,
+ {
+ let evaluated_batch = self.evaluate_batch(batch)?;
+ let state = self.state.building_mut();
+
+ let _timer = self.group_by_metrics.aggregation_time.timer();
+ for group_values in &evaluated_batch.grouping_set_args {
+ state
+ .group_values
+ .intern(group_values, &mut state.batch_group_indices)?;
+ let group_indices = &state.batch_group_indices;
+ let total_num_groups = state.group_values.len();
+
+ for (acc, values) in state
+ .accumulators
+ .iter_mut()
+ .zip(evaluated_batch.accumulator_args.iter())
+ {
+ aggregate_fn(acc, values, group_indices, total_num_groups)?;
+ }
+ }
+
+ Ok(())
+ }
+
+ /// Materializes the full output once, then returns it downstream
incrementally
+ /// by slicing it into `batch_size` chunks.
+ ///
+ /// Each aggregation mode chooses a different `materialize_accumulator_fn`
+ /// according to its semantics. For example, partial aggregation emits
+ /// partial states to feed the final stage, so it us
[`GroupsAccumulator::state`].
+ ///
+ /// This is a temporary solution until blocked state management is
implemented:
+ /// Issue: <https://github.com/apache/datafusion/issues/7065>
+ pub(super) fn next_output_batch_inner<F>(
Review Comment:
[4445f34](https://github.com/apache/datafusion/pull/23324/commits/4445f34df9682319df90b0f43a058fffa210fbcc)
--
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]