Skip to main content

Module aggregate

Module aggregate 

Source
Expand description

The run-time state of an aggregate node.

An aggregate folds a whole vector into one series per group, so its node is the one that cannot answer as its input arrives: a group’s value at a grid point is the fold of every value every member of the group has there, and the last member to arrive is the one that decides it. What the node keeps between chunks is therefore the fold’s states and nothing else – a chunk is folded as it arrives and dropped – and it produces once, when the input ends.

That is also why this runtime cannot tell an incomplete group from a complete one: it folds what it is handed. A AggregateStage::Complete aggregate is correct only if every contribution to each group lies within the streams this execution reads, which is the physical plan’s job – the caller that schedules scans and exchanges guarantees it, and a plan that ran a Complete aggregate once per partition and then combined the answers would be combining values that were each missing the other partitions’ contributions. The stages that exist for that shape are AggregateStage::Partial and AggregateStage::Final, which carry kernel accumulator state between executions.

quantile is the one aggregate here that is not a fold of each point’s values. Its answer is the φ-quantile of the group’s whole sample set at that point, so there is no fixed-width accumulator that answers it, and no state that combines two partitions’ quantiles into the quantile of their union. What the node keeps instead is its input: every series it was handed, until the input ends, when crate::aggregate::aggregate_quantile answers from all of it at once. That is also why quantile exists only as AggregateStage::Complete here, and why a plan that would have to fold it per partition has to keep the previous route instead of splitting it.

There is no spill either: a quantile keeps the whole input of every group, at once, until the last chunk arrives, so what it holds is not bounded by the number of groups the way a fixed-width accumulator’s is – it is bounded by the pool. Each chunk is admitted before it is kept and the reservation settles on the input retained so far (AggregateRuntime::accumulate), so a statement whose groups’ samples do not fit the pool is refused rather than served from disk, and a caller that needs an answer in bounded memory needs a wider pool rather than a wider node. Everything else in this runtime trades memory for the width of a point: a fold’s state per group and point, this one’s whole input.

Structs§

AggregateRuntime 🔒
One aggregate node’s states, from the first chunk it is handed to the series it finishes with.
QuantileInput 🔒
The input a quantile aggregate keeps, until it has all of it.

Enums§

AggregateOutput 🔒
The output shape produced by an aggregate stage.
Fold 🔒
What a Complete aggregate keeps while its input arrives.

Constants§

QUANTILE_PARAMETER_FIELD 🔒
The field the quantile parameter is bound under, which the kernel reads as its scalar.

Functions§

charge_samples 🔒
Charges the series a finished aggregate hands over, plus the queue they enter.
folded_chunk 🔒
The rejection of a chunk that is not the layout this node folds.
no_fold 🔒
The error for a fold that has already been finished.
quantile_parameter 🔒
The parameter a quantile reads at each point: the φ the query wrote, unlabelled and single field, at positions and nowhere else.
quantile_parameter_bound_bytes 🔒
The most a quantile parameter over input can cost, before it is built.
quantile_positions 🔒
The points the retained input holds, once each, in ascending order.
quantile_workspace_bytes 🔒
The bytes the quantile kernel needs beside its retained input while it answers.