Skip to main content

nominal_api_conjure/conjure/objects/scout/compute/api/
numeric_aggregation.rs

1/// Aggregates an input series using the given operator. The shape of the aggregation (rolling time window,
2/// rolling point-count window, or group by) is selected via the `AggregationBuilder` union.
3/// The operator needs to be compatible with the input series, producing a numeric output (e.g., count works for
4/// any type of input series whereas SUM only works for numeric series).
5#[derive(
6    Debug,
7    Clone,
8    conjure_object::serde::Serialize,
9    conjure_object::serde::Deserialize,
10    conjure_object::private::DeriveWith
11)]
12#[serde(crate = "conjure_object::serde")]
13#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
14#[conjure_object::private::staged_builder::staged_builder]
15#[builder(crate = conjure_object::private::staged_builder, update, inline)]
16pub struct NumericAggregation {
17    #[builder(custom(type = super::AggregationBuilder, convert = Box::new))]
18    #[serde(rename = "input")]
19    input: Box<super::AggregationBuilder>,
20    #[builder(custom(type = super::NumericAggregationOperator, convert = Box::new))]
21    #[serde(rename = "operator")]
22    operator: Box<super::NumericAggregationOperator>,
23}
24impl NumericAggregation {
25    /// Constructs a new instance of the type.
26    #[inline]
27    pub fn new(
28        input: super::AggregationBuilder,
29        operator: super::NumericAggregationOperator,
30    ) -> Self {
31        Self::builder().input(input).operator(operator).build()
32    }
33    /// The aggregation shape to apply the operator over: a rolling time window, a rolling
34    /// point-count window, or a group-by, selected via the `AggregationBuilder` union.
35    #[inline]
36    pub fn input(&self) -> &super::AggregationBuilder {
37        &*self.input
38    }
39    /// The reduction applied to each window or group (e.g. sum, mean, percentile). Must be
40    /// compatible with the input series, producing a numeric output: Count works on any input
41    /// series, whereas reductions like Sum require a numeric series.
42    #[inline]
43    pub fn operator(&self) -> &super::NumericAggregationOperator {
44        &*self.operator
45    }
46}