re_types/blueprint/archetypes/
dataframe_query.rs

1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs
2// Based on "crates/store/re_types/definitions/rerun/blueprint/archetypes/dataframe_query.fbs".
3
4#![allow(unused_braces)]
5#![allow(unused_imports)]
6#![allow(unused_parens)]
7#![allow(clippy::clone_on_copy)]
8#![allow(clippy::cloned_instead_of_copied)]
9#![allow(clippy::map_flatten)]
10#![allow(clippy::needless_question_mark)]
11#![allow(clippy::new_without_default)]
12#![allow(clippy::redundant_closure)]
13#![allow(clippy::too_many_arguments)]
14#![allow(clippy::too_many_lines)]
15
16use ::re_types_core::try_serialize_field;
17use ::re_types_core::SerializationResult;
18use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
19use ::re_types_core::{ComponentDescriptor, ComponentType};
20use ::re_types_core::{DeserializationError, DeserializationResult};
21
22/// **Archetype**: The query for the dataframe view.
23///
24/// ⚠️ **This type is _unstable_ and may change significantly in a way that the data won't be backwards compatible.**
25#[derive(Clone, Debug, Default)]
26pub struct DataframeQuery {
27    /// The timeline for this query.
28    ///
29    /// If unset, the timeline currently active on the time panel is used.
30    pub timeline: Option<SerializedComponentBatch>,
31
32    /// If provided, only rows whose timestamp is within this range will be shown.
33    ///
34    /// Note: will be unset as soon as `timeline` is changed.
35    pub filter_by_range: Option<SerializedComponentBatch>,
36
37    /// If provided, only show rows which contains a logged event for the specified component.
38    pub filter_is_not_null: Option<SerializedComponentBatch>,
39
40    /// Should empty cells be filled with latest-at queries?
41    pub apply_latest_at: Option<SerializedComponentBatch>,
42
43    /// Selected columns. If unset, all columns are selected.
44    pub select: Option<SerializedComponentBatch>,
45}
46
47impl DataframeQuery {
48    /// Returns the [`ComponentDescriptor`] for [`Self::timeline`].
49    ///
50    /// The corresponding component is [`crate::blueprint::components::TimelineName`].
51    #[inline]
52    pub fn descriptor_timeline() -> ComponentDescriptor {
53        ComponentDescriptor {
54            archetype: Some("rerun.blueprint.archetypes.DataframeQuery".into()),
55            component: "DataframeQuery:timeline".into(),
56            component_type: Some("rerun.blueprint.components.TimelineName".into()),
57        }
58    }
59
60    /// Returns the [`ComponentDescriptor`] for [`Self::filter_by_range`].
61    ///
62    /// The corresponding component is [`crate::blueprint::components::FilterByRange`].
63    #[inline]
64    pub fn descriptor_filter_by_range() -> ComponentDescriptor {
65        ComponentDescriptor {
66            archetype: Some("rerun.blueprint.archetypes.DataframeQuery".into()),
67            component: "DataframeQuery:filter_by_range".into(),
68            component_type: Some("rerun.blueprint.components.FilterByRange".into()),
69        }
70    }
71
72    /// Returns the [`ComponentDescriptor`] for [`Self::filter_is_not_null`].
73    ///
74    /// The corresponding component is [`crate::blueprint::components::FilterIsNotNull`].
75    #[inline]
76    pub fn descriptor_filter_is_not_null() -> ComponentDescriptor {
77        ComponentDescriptor {
78            archetype: Some("rerun.blueprint.archetypes.DataframeQuery".into()),
79            component: "DataframeQuery:filter_is_not_null".into(),
80            component_type: Some("rerun.blueprint.components.FilterIsNotNull".into()),
81        }
82    }
83
84    /// Returns the [`ComponentDescriptor`] for [`Self::apply_latest_at`].
85    ///
86    /// The corresponding component is [`crate::blueprint::components::ApplyLatestAt`].
87    #[inline]
88    pub fn descriptor_apply_latest_at() -> ComponentDescriptor {
89        ComponentDescriptor {
90            archetype: Some("rerun.blueprint.archetypes.DataframeQuery".into()),
91            component: "DataframeQuery:apply_latest_at".into(),
92            component_type: Some("rerun.blueprint.components.ApplyLatestAt".into()),
93        }
94    }
95
96    /// Returns the [`ComponentDescriptor`] for [`Self::select`].
97    ///
98    /// The corresponding component is [`crate::blueprint::components::SelectedColumns`].
99    #[inline]
100    pub fn descriptor_select() -> ComponentDescriptor {
101        ComponentDescriptor {
102            archetype: Some("rerun.blueprint.archetypes.DataframeQuery".into()),
103            component: "DataframeQuery:select".into(),
104            component_type: Some("rerun.blueprint.components.SelectedColumns".into()),
105        }
106    }
107}
108
109static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
110    once_cell::sync::Lazy::new(|| []);
111
112static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
113    once_cell::sync::Lazy::new(|| []);
114
115static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
116    once_cell::sync::Lazy::new(|| {
117        [
118            DataframeQuery::descriptor_timeline(),
119            DataframeQuery::descriptor_filter_by_range(),
120            DataframeQuery::descriptor_filter_is_not_null(),
121            DataframeQuery::descriptor_apply_latest_at(),
122            DataframeQuery::descriptor_select(),
123        ]
124    });
125
126static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
127    once_cell::sync::Lazy::new(|| {
128        [
129            DataframeQuery::descriptor_timeline(),
130            DataframeQuery::descriptor_filter_by_range(),
131            DataframeQuery::descriptor_filter_is_not_null(),
132            DataframeQuery::descriptor_apply_latest_at(),
133            DataframeQuery::descriptor_select(),
134        ]
135    });
136
137impl DataframeQuery {
138    /// The total number of components in the archetype: 0 required, 0 recommended, 5 optional
139    pub const NUM_COMPONENTS: usize = 5usize;
140}
141
142impl ::re_types_core::Archetype for DataframeQuery {
143    #[inline]
144    fn name() -> ::re_types_core::ArchetypeName {
145        "rerun.blueprint.archetypes.DataframeQuery".into()
146    }
147
148    #[inline]
149    fn display_name() -> &'static str {
150        "Dataframe query"
151    }
152
153    #[inline]
154    fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
155        REQUIRED_COMPONENTS.as_slice().into()
156    }
157
158    #[inline]
159    fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
160        RECOMMENDED_COMPONENTS.as_slice().into()
161    }
162
163    #[inline]
164    fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
165        OPTIONAL_COMPONENTS.as_slice().into()
166    }
167
168    #[inline]
169    fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
170        ALL_COMPONENTS.as_slice().into()
171    }
172
173    #[inline]
174    fn from_arrow_components(
175        arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
176    ) -> DeserializationResult<Self> {
177        re_tracing::profile_function!();
178        use ::re_types_core::{Loggable as _, ResultExt as _};
179        let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
180        let timeline = arrays_by_descr
181            .get(&Self::descriptor_timeline())
182            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_timeline()));
183        let filter_by_range = arrays_by_descr
184            .get(&Self::descriptor_filter_by_range())
185            .map(|array| {
186                SerializedComponentBatch::new(array.clone(), Self::descriptor_filter_by_range())
187            });
188        let filter_is_not_null = arrays_by_descr
189            .get(&Self::descriptor_filter_is_not_null())
190            .map(|array| {
191                SerializedComponentBatch::new(array.clone(), Self::descriptor_filter_is_not_null())
192            });
193        let apply_latest_at = arrays_by_descr
194            .get(&Self::descriptor_apply_latest_at())
195            .map(|array| {
196                SerializedComponentBatch::new(array.clone(), Self::descriptor_apply_latest_at())
197            });
198        let select = arrays_by_descr
199            .get(&Self::descriptor_select())
200            .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_select()));
201        Ok(Self {
202            timeline,
203            filter_by_range,
204            filter_is_not_null,
205            apply_latest_at,
206            select,
207        })
208    }
209}
210
211impl ::re_types_core::AsComponents for DataframeQuery {
212    #[inline]
213    fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
214        use ::re_types_core::Archetype as _;
215        [
216            self.timeline.clone(),
217            self.filter_by_range.clone(),
218            self.filter_is_not_null.clone(),
219            self.apply_latest_at.clone(),
220            self.select.clone(),
221        ]
222        .into_iter()
223        .flatten()
224        .collect()
225    }
226}
227
228impl ::re_types_core::ArchetypeReflectionMarker for DataframeQuery {}
229
230impl DataframeQuery {
231    /// Create a new `DataframeQuery`.
232    #[inline]
233    pub fn new() -> Self {
234        Self {
235            timeline: None,
236            filter_by_range: None,
237            filter_is_not_null: None,
238            apply_latest_at: None,
239            select: None,
240        }
241    }
242
243    /// Update only some specific fields of a `DataframeQuery`.
244    #[inline]
245    pub fn update_fields() -> Self {
246        Self::default()
247    }
248
249    /// Clear all the fields of a `DataframeQuery`.
250    #[inline]
251    pub fn clear_fields() -> Self {
252        use ::re_types_core::Loggable as _;
253        Self {
254            timeline: Some(SerializedComponentBatch::new(
255                crate::blueprint::components::TimelineName::arrow_empty(),
256                Self::descriptor_timeline(),
257            )),
258            filter_by_range: Some(SerializedComponentBatch::new(
259                crate::blueprint::components::FilterByRange::arrow_empty(),
260                Self::descriptor_filter_by_range(),
261            )),
262            filter_is_not_null: Some(SerializedComponentBatch::new(
263                crate::blueprint::components::FilterIsNotNull::arrow_empty(),
264                Self::descriptor_filter_is_not_null(),
265            )),
266            apply_latest_at: Some(SerializedComponentBatch::new(
267                crate::blueprint::components::ApplyLatestAt::arrow_empty(),
268                Self::descriptor_apply_latest_at(),
269            )),
270            select: Some(SerializedComponentBatch::new(
271                crate::blueprint::components::SelectedColumns::arrow_empty(),
272                Self::descriptor_select(),
273            )),
274        }
275    }
276
277    /// The timeline for this query.
278    ///
279    /// If unset, the timeline currently active on the time panel is used.
280    #[inline]
281    pub fn with_timeline(
282        mut self,
283        timeline: impl Into<crate::blueprint::components::TimelineName>,
284    ) -> Self {
285        self.timeline = try_serialize_field(Self::descriptor_timeline(), [timeline]);
286        self
287    }
288
289    /// If provided, only rows whose timestamp is within this range will be shown.
290    ///
291    /// Note: will be unset as soon as `timeline` is changed.
292    #[inline]
293    pub fn with_filter_by_range(
294        mut self,
295        filter_by_range: impl Into<crate::blueprint::components::FilterByRange>,
296    ) -> Self {
297        self.filter_by_range =
298            try_serialize_field(Self::descriptor_filter_by_range(), [filter_by_range]);
299        self
300    }
301
302    /// If provided, only show rows which contains a logged event for the specified component.
303    #[inline]
304    pub fn with_filter_is_not_null(
305        mut self,
306        filter_is_not_null: impl Into<crate::blueprint::components::FilterIsNotNull>,
307    ) -> Self {
308        self.filter_is_not_null =
309            try_serialize_field(Self::descriptor_filter_is_not_null(), [filter_is_not_null]);
310        self
311    }
312
313    /// Should empty cells be filled with latest-at queries?
314    #[inline]
315    pub fn with_apply_latest_at(
316        mut self,
317        apply_latest_at: impl Into<crate::blueprint::components::ApplyLatestAt>,
318    ) -> Self {
319        self.apply_latest_at =
320            try_serialize_field(Self::descriptor_apply_latest_at(), [apply_latest_at]);
321        self
322    }
323
324    /// Selected columns. If unset, all columns are selected.
325    #[inline]
326    pub fn with_select(
327        mut self,
328        select: impl Into<crate::blueprint::components::SelectedColumns>,
329    ) -> Self {
330        self.select = try_serialize_field(Self::descriptor_select(), [select]);
331        self
332    }
333}
334
335impl ::re_byte_size::SizeBytes for DataframeQuery {
336    #[inline]
337    fn heap_size_bytes(&self) -> u64 {
338        self.timeline.heap_size_bytes()
339            + self.filter_by_range.heap_size_bytes()
340            + self.filter_is_not_null.heap_size_bytes()
341            + self.apply_latest_at.heap_size_bytes()
342            + self.select.heap_size_bytes()
343    }
344}