re_types/blueprint/archetypes/
dataframe_query.rs1#![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#[derive(Clone, Debug, Default)]
26pub struct DataframeQuery {
27 pub timeline: Option<SerializedComponentBatch>,
31
32 pub filter_by_range: Option<SerializedComponentBatch>,
36
37 pub filter_is_not_null: Option<SerializedComponentBatch>,
39
40 pub apply_latest_at: Option<SerializedComponentBatch>,
42
43 pub select: Option<SerializedComponentBatch>,
45}
46
47impl DataframeQuery {
48 #[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 #[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 #[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 #[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 #[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 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 #[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 #[inline]
245 pub fn update_fields() -> Self {
246 Self::default()
247 }
248
249 #[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 #[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 #[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 #[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 #[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 #[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}