Skip to main content

map_arithmetic_series

Function map_arithmetic_series 

Source
pub fn map_arithmetic_series(
    schema: &Arc<SeriesSchema>,
    vector: &Series,
    op: ArithmeticOp,
    scalar: ScalarSeriesOperand<'_>,
) -> Result<Option<Series>>
Expand description

Applies arithmetic between vector fields and a time-varying scalar, aligned by absolute grid index, and drops the metric name.

Prometheus scalars exist at every step; a missing scalar point here yields a missing output. The output covers the valid rows and nothing else, and None means there is none. A scalar point holding no value is a hole in the one result series, not the end of a piece: the axis names the runs of consecutive valid positions. The scalar must be unlabelled and single-field on the same grid; histogram/mixed/raw inputs are rejected even outside the overlap. Both operands may skip positions: only the positions both carry are evaluated, and the two axes are aligned by intersecting their runs, never by subtracting one axis’ first position from the other’s indices. Two unlabelled single-field inputs also evaluate scalar–scalar operations. Same-labelset merging is left to the caller, as in crate::map::map_math.