Skip to main content

check_datums_fit_budget

Function check_datums_fit_budget 

Source
pub fn check_datums_fit_budget<'a>(
    datums: impl IntoIterator<Item = Datum<'a>>,
    temp_storage: &RowArena,
) -> Result<(), EvalError>
Expand description

Refuses a collection temp_storage’s budget cannot afford, before it is packed.

The collection builders (ARRAY[..], LIST[..], ROW(..), MAP[..], jsonb_build_*) pack the datums they are handed straight into temp_storage, so the result is as large as those datums times however many times the expression names each one. Unlike the string functions bounded by max_string_func_result_bytes, ARRAY[body, body, ..] has no ceiling of its own.

Like that ceiling, this must be consulted before the result is built, since the arena’s budget is only observable once the bytes exist. mz_repr::datum_size is the size a datum occupies once packed, so summing it bounds the result without allocating anything. Without a budget budget_remaining is usize::MAX and nothing is refused.