Skip to main content

nominal_api/conjure/objects/storage/writer/api/
column_batch.rs

1/// Batch of data to stream for a single channel with their associated timestamps.
2#[derive(
3    Debug,
4    Clone,
5    conjure_object::serde::Serialize,
6    conjure_object::serde::Deserialize,
7    conjure_object::private::DeriveWith
8)]
9#[serde(crate = "conjure_object::serde")]
10#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
11#[conjure_object::private::staged_builder::staged_builder]
12#[builder(crate = conjure_object::private::staged_builder, update, inline)]
13pub struct ColumnBatch {
14    #[serde(rename = "channel")]
15    channel: super::super::super::super::api::Channel,
16    #[builder(
17        default,
18        map(
19            key(type = super::super::super::super::api::TagName),
20            value(type = super::super::super::super::api::TagValue)
21        )
22    )]
23    #[serde(
24        rename = "tags",
25        skip_serializing_if = "std::collections::BTreeMap::is_empty",
26        default
27    )]
28    tags: std::collections::BTreeMap<
29        super::super::super::super::api::TagName,
30        super::super::super::super::api::TagValue,
31    >,
32    #[builder(default, list(item(type = super::super::super::super::api::Timestamp)))]
33    #[serde(rename = "timestamps", skip_serializing_if = "Vec::is_empty", default)]
34    timestamps: Vec<super::super::super::super::api::Timestamp>,
35    #[builder(custom(type = super::ColumnValues, convert = Box::new))]
36    #[serde(rename = "values")]
37    values: Box<super::ColumnValues>,
38}
39impl ColumnBatch {
40    /// Constructs a new instance of the type.
41    #[inline]
42    pub fn new(
43        channel: super::super::super::super::api::Channel,
44        values: super::ColumnValues,
45    ) -> Self {
46        Self::builder().channel(channel).values(values).build()
47    }
48    /// Channel within nominal to stream data to.
49    #[inline]
50    pub fn channel(&self) -> &super::super::super::super::api::Channel {
51        &self.channel
52    }
53    /// Mapping of key-value pairs to provide as tags to all points within the batch
54    #[inline]
55    pub fn tags(
56        &self,
57    ) -> &std::collections::BTreeMap<
58        super::super::super::super::api::TagName,
59        super::super::super::super::api::TagValue,
60    > {
61        &self.tags
62    }
63    /// List of timestamp values that correspond to the provided list of column values. The number of timestamps
64    /// provided MUST match the number of columnar values provided, otherwise a 400 error will be returned.
65    #[inline]
66    pub fn timestamps(&self) -> &[super::super::super::super::api::Timestamp] {
67        &*self.timestamps
68    }
69    /// List of time series values that should be ingested to a single channel. The number of columnar values
70    /// provided MUST match the number of timestamps provided, otherwise a 400 error will be returned.
71    #[inline]
72    pub fn values(&self) -> &super::ColumnValues {
73        &*self.values
74    }
75}