Skip to main content

nominal_api/conjure/objects/scout/compute/api/
aggregate_numeric_series.rs

1/// DEPRECATED. Use a dedicated group-by-and-aggregate nodes instead.
2///
3/// Aggregates values with duplicate timestamps in the input series values into a single value using the
4/// specified aggregation function.
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 AggregateNumericSeries {
17    #[builder(custom(type = super::NumericSeries, convert = Box::new))]
18    #[serde(rename = "input")]
19    input: Box<super::NumericSeries>,
20    #[serde(rename = "function")]
21    function: super::NumericAggregationFunction,
22    #[builder(default, set(item(type = super::StringConstant)))]
23    #[serde(
24        rename = "groupByTags",
25        skip_serializing_if = "std::collections::BTreeSet::is_empty",
26        default
27    )]
28    group_by_tags: std::collections::BTreeSet<super::StringConstant>,
29    #[builder(default, into)]
30    #[serde(
31        rename = "aggregateByAllGroupings",
32        skip_serializing_if = "Option::is_none",
33        default
34    )]
35    aggregate_by_all_groupings: Option<bool>,
36    #[builder(
37        default,
38        custom(
39            type = impl
40            Into<Option<super::InterpolationConfiguration>>,
41            convert = |v|v.into().map(Box::new)
42        )
43    )]
44    #[serde(
45        rename = "interpolationConfiguration",
46        skip_serializing_if = "Option::is_none",
47        default
48    )]
49    interpolation_configuration: Option<Box<super::InterpolationConfiguration>>,
50}
51impl AggregateNumericSeries {
52    /// Constructs a new instance of the type.
53    #[inline]
54    pub fn new(
55        input: super::NumericSeries,
56        function: super::NumericAggregationFunction,
57    ) -> Self {
58        Self::builder().input(input).function(function).build()
59    }
60    #[inline]
61    pub fn input(&self) -> &super::NumericSeries {
62        &*self.input
63    }
64    #[inline]
65    pub fn function(&self) -> &super::NumericAggregationFunction {
66        &self.function
67    }
68    /// Tags to group by for the aggregation.
69    /// If left empty, the tags to group by will be equivalent to those in the input series.
70    /// If specified, the result will be grouped ONLY by the specified tags.
71    /// The tags specified here MUST be a (non-strict) subset of the input series's group by tags.
72    #[inline]
73    pub fn group_by_tags(&self) -> &std::collections::BTreeSet<super::StringConstant> {
74        &self.group_by_tags
75    }
76    /// This field's purpose is to distinguish between the two flavors of groupByTags being empty. It has no
77    /// effect when groupByTags is non-empty.
78    /// When true and groupByTags is empty, aggregate across all series in the input.
79    /// When false and groupByTags is empty, the result will be grouped by the same tags as the input series.
80    #[inline]
81    pub fn aggregate_by_all_groupings(&self) -> Option<bool> {
82        self.aggregate_by_all_groupings.as_ref().map(|o| *o)
83    }
84    /// If provided, interpolates values at timestamps where the input series has values before aggregating.
85    /// If not provided, only aggregates when timestamps match exactly (existing behavior).
86    #[inline]
87    pub fn interpolation_configuration(
88        &self,
89    ) -> Option<&super::InterpolationConfiguration> {
90        self.interpolation_configuration.as_ref().map(|o| &**o)
91    }
92}