File tree Expand file tree Collapse file tree
physical-plan/src/aggregates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,9 @@ pub trait GroupsAccumulator: Send {
128128 /// Returns the intermediate aggregate state for this accumulator,
129129 /// used for multi-phase grouping, resetting its internal state.
130130 ///
131+ /// See [`Accumulator::state`] for more information on multi-phase
132+ /// aggregation.
133+ ///
131134 /// For example, `AVG` might return two arrays: `SUM` and `COUNT`
132135 /// but the `MIN` aggregate would just return a single array.
133136 ///
@@ -159,7 +162,9 @@ pub trait GroupsAccumulator: Send {
159162 ) -> Result < ( ) > ;
160163
161164 /// Amount of memory used to store the state of this accumulator,
162- /// in bytes. This function is called once per batch, so it should
163- /// be `O(n)` to compute, not `O(num_groups)`
165+ /// in bytes.
166+ ///
167+ /// This function is called once per batch, so it should be `O(n)` to
168+ /// compute, not `O(num_groups)`
164169 fn size ( & self ) -> usize ;
165170}
Original file line number Diff line number Diff line change @@ -72,8 +72,7 @@ pub enum AggregateMode {
7272 /// Final aggregate that produces a single partition of output by combining
7373 /// the output of multiple partial aggregates.
7474 ///
75- /// This is the second phase of a
76- /// multi-phase aggregation.
75+ /// This is the second phase of a multi-phase aggregation.
7776 Final ,
7877 /// Final aggregate that works on pre-partitioned data.
7978 ///
@@ -92,7 +91,8 @@ pub enum AggregateMode {
9291 /// as opposed to Partial / Final modes which apply the logical aggregation using
9392 /// two operators.
9493 ///
95- /// This mode requires that the input is partitioned by group key (like FinalPartitioned)
94+ /// This mode requires that the input is partitioned by group key (like
95+ /// FinalPartitioned)
9696 SinglePartitioned ,
9797}
9898
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ struct SpillState {
137137/// of `x` and one accumulator for `SUM(y)`, specialized for the data
138138/// type of `y`.
139139///
140- /// # Description
140+ /// # Discussion
141141///
142142/// [`group_values`] does not store any aggregate state inline. It only
143143/// assigns "group indices", one for each (distinct) group value. The
@@ -160,9 +160,12 @@ struct SpillState {
160160/// As described on [`Accumulator::state`], this operator is used in the context
161161/// "multi-phase" grouping when the mode is [`AggregateMode::Partial`].
162162///
163+ /// An important optimization for partial aggregation
164+ ///
165+ ///
163166/// [`Accumulator::state`]: datafusion_expr::Accumulator::state
164167///
165- /// # Spilling
168+ /// # Spilling (to disk)
166169///
167170/// The sizes of group values and accumulators can become large. Before that causes out of memory,
168171/// this hash aggregator outputs partial states early for partial aggregation or spills to local
You can’t perform that action at this time.
0 commit comments