1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/// A user-defined numeric aggregation. The aggregation builder controls grouping/windowing.
/// Supported Rust entrypoints accept grouped value vectors, optionally with leading sample timestamps,
/// and return either one numeric value or timestamped numeric point(s), e.g.
/// `fn rms(values: Vec<f64>) -> f64`,
/// `fn energy(timestamp_ns: Vec<i64>, values: Vec<f64>) -> f64`,
/// `fn first(timestamp_ns: Vec<i64>, values: Vec<f64>) -> (i64, f64)`, or
/// `fn passthrough(timestamp_ns: Vec<i64>, values: Vec<f64>) -> Vec<(i64, f64)>`.
/// The value vector's element type follows the aggregated series: `Vec<f64>` for a numeric series, and
/// `Vec<String>` for a categorical or struct series, where each struct row arrives as a JSON object. A UDF
/// over a combined struct series may instead take one vector per named struct field it needs, e.g.
/// `fn mean_product(channel0: Vec<f64>, channel1: Vec<f64>) -> f64`.
/// Parameter names select the fields, so a subset of the struct's fields in any order is accepted.
#[derive(
Debug,
Clone,
conjure_object::serde::Serialize,
conjure_object::serde::Deserialize,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash
)]
#[serde(crate = "conjure_object::serde")]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct NumericAggregationUdf {
#[builder(custom(type = super::UdfSource, convert = Box::new))]
#[serde(rename = "source")]
source: Box<super::UdfSource>,
}
impl NumericAggregationUdf {
/// Constructs a new instance of the type.
#[inline]
pub fn new(source: super::UdfSource) -> Self {
Self::builder().source(source).build()
}
#[inline]
pub fn source(&self) -> &super::UdfSource {
&*self.source
}
}