1#![allow(unused_imports)]
5#![allow(unused_parens)]
6#![allow(clippy::clone_on_copy)]
7#![allow(clippy::cloned_instead_of_copied)]
8#![allow(clippy::map_flatten)]
9#![allow(clippy::needless_question_mark)]
10#![allow(clippy::new_without_default)]
11#![allow(clippy::redundant_closure)]
12#![allow(clippy::too_many_arguments)]
13#![allow(clippy::too_many_lines)]
14
15use ::re_types_core::try_serialize_field;
16use ::re_types_core::SerializationResult;
17use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
18use ::re_types_core::{ComponentDescriptor, ComponentName};
19use ::re_types_core::{DeserializationError, DeserializationResult};
20
21#[derive(Clone, Debug, Default)]
78pub struct SeriesPoints {
79 pub colors: Option<SerializedComponentBatch>,
83
84 pub markers: Option<SerializedComponentBatch>,
88
89 pub names: Option<SerializedComponentBatch>,
93
94 pub visible_series: Option<SerializedComponentBatch>,
102
103 pub marker_sizes: Option<SerializedComponentBatch>,
107}
108
109impl SeriesPoints {
110 #[inline]
112 pub fn descriptor_colors() -> ComponentDescriptor {
113 ComponentDescriptor {
114 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
115 component_name: "rerun.components.Color".into(),
116 archetype_field_name: Some("colors".into()),
117 }
118 }
119
120 #[inline]
122 pub fn descriptor_markers() -> ComponentDescriptor {
123 ComponentDescriptor {
124 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
125 component_name: "rerun.components.MarkerShape".into(),
126 archetype_field_name: Some("markers".into()),
127 }
128 }
129
130 #[inline]
132 pub fn descriptor_names() -> ComponentDescriptor {
133 ComponentDescriptor {
134 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
135 component_name: "rerun.components.Name".into(),
136 archetype_field_name: Some("names".into()),
137 }
138 }
139
140 #[inline]
142 pub fn descriptor_visible_series() -> ComponentDescriptor {
143 ComponentDescriptor {
144 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
145 component_name: "rerun.components.SeriesVisible".into(),
146 archetype_field_name: Some("visible_series".into()),
147 }
148 }
149
150 #[inline]
152 pub fn descriptor_marker_sizes() -> ComponentDescriptor {
153 ComponentDescriptor {
154 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
155 component_name: "rerun.components.MarkerSize".into(),
156 archetype_field_name: Some("marker_sizes".into()),
157 }
158 }
159
160 #[inline]
162 pub fn descriptor_indicator() -> ComponentDescriptor {
163 ComponentDescriptor {
164 archetype_name: Some("rerun.archetypes.SeriesPoints".into()),
165 component_name: "rerun.components.SeriesPointsIndicator".into(),
166 archetype_field_name: None,
167 }
168 }
169}
170
171static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
172 once_cell::sync::Lazy::new(|| []);
173
174static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
175 once_cell::sync::Lazy::new(|| [SeriesPoints::descriptor_indicator()]);
176
177static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 5usize]> =
178 once_cell::sync::Lazy::new(|| {
179 [
180 SeriesPoints::descriptor_colors(),
181 SeriesPoints::descriptor_markers(),
182 SeriesPoints::descriptor_names(),
183 SeriesPoints::descriptor_visible_series(),
184 SeriesPoints::descriptor_marker_sizes(),
185 ]
186 });
187
188static ALL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 6usize]> =
189 once_cell::sync::Lazy::new(|| {
190 [
191 SeriesPoints::descriptor_indicator(),
192 SeriesPoints::descriptor_colors(),
193 SeriesPoints::descriptor_markers(),
194 SeriesPoints::descriptor_names(),
195 SeriesPoints::descriptor_visible_series(),
196 SeriesPoints::descriptor_marker_sizes(),
197 ]
198 });
199
200impl SeriesPoints {
201 pub const NUM_COMPONENTS: usize = 6usize;
203}
204
205pub type SeriesPointsIndicator = ::re_types_core::GenericIndicatorComponent<SeriesPoints>;
207
208impl ::re_types_core::Archetype for SeriesPoints {
209 type Indicator = SeriesPointsIndicator;
210
211 #[inline]
212 fn name() -> ::re_types_core::ArchetypeName {
213 "rerun.archetypes.SeriesPoints".into()
214 }
215
216 #[inline]
217 fn display_name() -> &'static str {
218 "Series points"
219 }
220
221 #[inline]
222 fn indicator() -> SerializedComponentBatch {
223 #[allow(clippy::unwrap_used)]
224 SeriesPointsIndicator::DEFAULT.serialized().unwrap()
225 }
226
227 #[inline]
228 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
229 REQUIRED_COMPONENTS.as_slice().into()
230 }
231
232 #[inline]
233 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
234 RECOMMENDED_COMPONENTS.as_slice().into()
235 }
236
237 #[inline]
238 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
239 OPTIONAL_COMPONENTS.as_slice().into()
240 }
241
242 #[inline]
243 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
244 ALL_COMPONENTS.as_slice().into()
245 }
246
247 #[inline]
248 fn from_arrow_components(
249 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
250 ) -> DeserializationResult<Self> {
251 re_tracing::profile_function!();
252 use ::re_types_core::{Loggable as _, ResultExt as _};
253 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
254 let colors = arrays_by_descr
255 .get(&Self::descriptor_colors())
256 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
257 let markers = arrays_by_descr
258 .get(&Self::descriptor_markers())
259 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_markers()));
260 let names = arrays_by_descr
261 .get(&Self::descriptor_names())
262 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_names()));
263 let visible_series = arrays_by_descr
264 .get(&Self::descriptor_visible_series())
265 .map(|array| {
266 SerializedComponentBatch::new(array.clone(), Self::descriptor_visible_series())
267 });
268 let marker_sizes = arrays_by_descr
269 .get(&Self::descriptor_marker_sizes())
270 .map(|array| {
271 SerializedComponentBatch::new(array.clone(), Self::descriptor_marker_sizes())
272 });
273 Ok(Self {
274 colors,
275 markers,
276 names,
277 visible_series,
278 marker_sizes,
279 })
280 }
281}
282
283impl ::re_types_core::AsComponents for SeriesPoints {
284 #[inline]
285 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
286 use ::re_types_core::Archetype as _;
287 [
288 Some(Self::indicator()),
289 self.colors.clone(),
290 self.markers.clone(),
291 self.names.clone(),
292 self.visible_series.clone(),
293 self.marker_sizes.clone(),
294 ]
295 .into_iter()
296 .flatten()
297 .collect()
298 }
299}
300
301impl ::re_types_core::ArchetypeReflectionMarker for SeriesPoints {}
302
303impl SeriesPoints {
304 #[inline]
306 pub fn new() -> Self {
307 Self {
308 colors: None,
309 markers: None,
310 names: None,
311 visible_series: None,
312 marker_sizes: None,
313 }
314 }
315
316 #[inline]
318 pub fn update_fields() -> Self {
319 Self::default()
320 }
321
322 #[inline]
324 pub fn clear_fields() -> Self {
325 use ::re_types_core::Loggable as _;
326 Self {
327 colors: Some(SerializedComponentBatch::new(
328 crate::components::Color::arrow_empty(),
329 Self::descriptor_colors(),
330 )),
331 markers: Some(SerializedComponentBatch::new(
332 crate::components::MarkerShape::arrow_empty(),
333 Self::descriptor_markers(),
334 )),
335 names: Some(SerializedComponentBatch::new(
336 crate::components::Name::arrow_empty(),
337 Self::descriptor_names(),
338 )),
339 visible_series: Some(SerializedComponentBatch::new(
340 crate::components::SeriesVisible::arrow_empty(),
341 Self::descriptor_visible_series(),
342 )),
343 marker_sizes: Some(SerializedComponentBatch::new(
344 crate::components::MarkerSize::arrow_empty(),
345 Self::descriptor_marker_sizes(),
346 )),
347 }
348 }
349
350 #[inline]
361 pub fn columns<I>(
362 self,
363 _lengths: I,
364 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
365 where
366 I: IntoIterator<Item = usize> + Clone,
367 {
368 let columns = [
369 self.colors
370 .map(|colors| colors.partitioned(_lengths.clone()))
371 .transpose()?,
372 self.markers
373 .map(|markers| markers.partitioned(_lengths.clone()))
374 .transpose()?,
375 self.names
376 .map(|names| names.partitioned(_lengths.clone()))
377 .transpose()?,
378 self.visible_series
379 .map(|visible_series| visible_series.partitioned(_lengths.clone()))
380 .transpose()?,
381 self.marker_sizes
382 .map(|marker_sizes| marker_sizes.partitioned(_lengths.clone()))
383 .transpose()?,
384 ];
385 Ok(columns
386 .into_iter()
387 .flatten()
388 .chain([::re_types_core::indicator_column::<Self>(
389 _lengths.into_iter().count(),
390 )?]))
391 }
392
393 #[inline]
398 pub fn columns_of_unit_batches(
399 self,
400 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
401 let len_colors = self.colors.as_ref().map(|b| b.array.len());
402 let len_markers = self.markers.as_ref().map(|b| b.array.len());
403 let len_names = self.names.as_ref().map(|b| b.array.len());
404 let len_visible_series = self.visible_series.as_ref().map(|b| b.array.len());
405 let len_marker_sizes = self.marker_sizes.as_ref().map(|b| b.array.len());
406 let len = None
407 .or(len_colors)
408 .or(len_markers)
409 .or(len_names)
410 .or(len_visible_series)
411 .or(len_marker_sizes)
412 .unwrap_or(0);
413 self.columns(std::iter::repeat(1).take(len))
414 }
415
416 #[inline]
420 pub fn with_colors(
421 mut self,
422 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
423 ) -> Self {
424 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
425 self
426 }
427
428 #[inline]
432 pub fn with_markers(
433 mut self,
434 markers: impl IntoIterator<Item = impl Into<crate::components::MarkerShape>>,
435 ) -> Self {
436 self.markers = try_serialize_field(Self::descriptor_markers(), markers);
437 self
438 }
439
440 #[inline]
444 pub fn with_names(
445 mut self,
446 names: impl IntoIterator<Item = impl Into<crate::components::Name>>,
447 ) -> Self {
448 self.names = try_serialize_field(Self::descriptor_names(), names);
449 self
450 }
451
452 #[inline]
460 pub fn with_visible_series(
461 mut self,
462 visible_series: impl IntoIterator<Item = impl Into<crate::components::SeriesVisible>>,
463 ) -> Self {
464 self.visible_series =
465 try_serialize_field(Self::descriptor_visible_series(), visible_series);
466 self
467 }
468
469 #[inline]
473 pub fn with_marker_sizes(
474 mut self,
475 marker_sizes: impl IntoIterator<Item = impl Into<crate::components::MarkerSize>>,
476 ) -> Self {
477 self.marker_sizes = try_serialize_field(Self::descriptor_marker_sizes(), marker_sizes);
478 self
479 }
480}
481
482impl ::re_byte_size::SizeBytes for SeriesPoints {
483 #[inline]
484 fn heap_size_bytes(&self) -> u64 {
485 self.colors.heap_size_bytes()
486 + self.markers.heap_size_bytes()
487 + self.names.heap_size_bytes()
488 + self.visible_series.heap_size_bytes()
489 + self.marker_sizes.heap_size_bytes()
490 }
491}