Skip to content

Commit e151786

Browse files
committed
more background
1 parent ffa7d1a commit e151786

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

datafusion/expr/src/accumulator.rs

+43
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,49 @@ pub trait Accumulator: Send + Sync + Debug {
206206
/// that each distinct group key appears in exactly one of the
207207
/// `AggregateMode::Final` GroupBy nodes. The output of the final nodes are
208208
/// then unioned together to produce the overall final output.
209+
///
210+
/// Here is an example that shows the distribution of groups in the
211+
/// different phases
212+
///
213+
/// ```text
214+
/// ┌─────┐ ┌─────┐
215+
/// │ 1 │ │ 3 │
216+
/// ├─────┤ ├─────┤
217+
/// │ 2 │ │ 4 │ After repartitioning by
218+
/// └─────┘ └─────┘ hash(group keys), each distinct
219+
/// ┌─────┐ ┌─────┐ group key now appears in exactly
220+
/// │ 1 │ │ 3 │ one partition
221+
/// ├─────┤ ├─────┤
222+
/// │ 2 │ │ 4 │
223+
/// └─────┘ └─────┘
224+
///
225+
///
226+
/// ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─
227+
///
228+
/// ┌─────┐ ┌─────┐
229+
/// │ 2 │ │ 2 │
230+
/// ├─────┤ ├─────┤
231+
/// │ 1 │ │ 2 │
232+
/// ├─────┤ ├─────┤
233+
/// │ 3 │ │ 3 │
234+
/// ├─────┤ ├─────┤
235+
/// │ 4 │ │ 1 │
236+
/// └─────┘ └─────┘ Input data is arbitrarily or
237+
/// ... ... RoundRobin distributed, each
238+
/// ┌─────┐ ┌─────┐ partition likely has all
239+
/// │ 1 │ │ 4 │ distinct group keys
240+
/// ├─────┤ ├─────┤
241+
/// │ 4 │ │ 3 │
242+
/// ├─────┤ ├─────┤
243+
/// │ 1 │ │ 1 │
244+
/// ├─────┤ ├─────┤
245+
/// │ 4 │ │ 3 │
246+
/// └─────┘ └─────┘
247+
///
248+
/// group values group values
249+
/// in partition 0 in partition 1
250+
///
251+
/// ```
209252
fn state(&mut self) -> Result<Vec<ScalarValue>>;
210253

211254
/// Updates the accumulator's state from an `Array` containing one

0 commit comments

Comments
 (0)