Skip to main content

nominal_api/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 vs.
2/// 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    #[inline]
34    pub fn input(&self) -> &super::AggregationBuilder {
35        &*self.input
36    }
37    #[inline]
38    pub fn operator(&self) -> &super::NumericAggregationOperator {
39        &*self.operator
40    }
41}