Skip to main content

Module aggregate_helpers

Module aggregate_helpers 

Source
Expand description

Public helpers for streaming aggregate accumulators.

These thin wrappers expose field-extraction primitives used by the streaming aggregate accumulators in the nodedb crate. Each function operates on a single raw MessagePack document byte slice and returns only the scalar value needed by the calling accumulator — no document bytes are retained after the call returns.

Functions§

extract_bytes
Extract a field or expression result as raw msgpack bytes. Used by count_distinct, approx_count_distinct, approx_topk, etc.
extract_f64
Extract a numeric (f64) value from field, or evaluate expr if provided. Returns Ok(None) when the field is absent or cannot be converted to f64, and Err(EvalError::DivisionByZero) when expr divides/mods by zero.
extract_non_null
Returns Ok(Some(())) when the field is present and non-null. Used by count(field) accumulator to count non-null values.
extract_str
Extract a display string from field, or evaluate expr if provided. Returns Ok(None) when the field is absent.
extract_sum_value
Extract the SUM / AVG input of field, or of expr if provided, as the number it contributes (Integer, Float, or Decimal). A raw field and an expression result contribute by the same rule, crate::numeric_sum::sum_input: a msgpack number read exactly, or a numeric string read per crate::numeric_sum::numeric_text (a DECIMAL cell is stored as its text). Returns Ok(None) when nothing contributes, and Err(EvalError::DivisionByZero) when expr divides/mods by zero.
extract_value
Extract a field as Value. Uses direct msgpack→Value for scalars; falls back to full document decode only for complex types.