Skip to main content

quantile_workspace_bytes

Function quantile_workspace_bytes 

Source
fn quantile_workspace_bytes(
    schema: &SeriesSchema,
    input: &QuantileInput,
    parameter_points: usize,
) -> usize
Expand description

The bytes the quantile kernel needs beside its retained input while it answers.

aggregate_quantile reports no workspace as it allocates, so this is an estimate reserved once before it runs, in the same spirit as the whole-vector kernels’. What it covers: the state it keeps per member (one position list, one heap entry and one cursor per field), its own copy of the parameter, the temporaries of one grid point (its members’ values, the copy the kernel sorts, and one row of the width it folds), and the rows it builds – the group being built and the groups it has already handed over. The row count is the input’s own: a group’s rows are the points at least one of its members holds a sample at, so the input’s rows bound every group’s rows and their sum.

The parameter copy is parameter_points pairs and not the input’s rows: the kernel reads the whole parameter into one (position, φ) per point it covers before it folds anything, so a dense time() read against one row of input copies every point of the grid, and sizing that copy from the input’s one row would reserve a pair for a million points. What the kernel iterates are the parameter’s own positions – the points a bound φ was built over and the points a held one covers – so the caller reports that count rather than this reading the input for it.