1#![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)]
79pub struct SeriesPoints {
80 pub colors: Option<SerializedComponentBatch>,
84
85 pub markers: Option<SerializedComponentBatch>,
89
90 pub names: Option<SerializedComponentBatch>,
94
95 pub visible_series: Option<SerializedComponentBatch>,
103
104 pub marker_sizes: Option<SerializedComponentBatch>,
108}
109
110impl SeriesPoints {
111 #[inline]
115 pub fn descriptor_colors() -> ComponentDescriptor {
116 ComponentDescriptor {
117 archetype: Some("rerun.archetypes.SeriesPoints".into()),
118 component: "SeriesPoints:colors".into(),
119 component_type: Some("rerun.components.Color".into()),
120 }
121 }
122
123 #[inline]
127 pub fn descriptor_markers() -> ComponentDescriptor {
128 ComponentDescriptor {
129 archetype: Some("rerun.archetypes.SeriesPoints".into()),
130 component: "SeriesPoints:markers".into(),
131 component_type: Some("rerun.components.MarkerShape".into()),
132 }
133 }
134
135 #[inline]
139 pub fn descriptor_names() -> ComponentDescriptor {
140 ComponentDescriptor {
141 archetype: Some("rerun.archetypes.SeriesPoints".into()),
142 component: "SeriesPoints:names".into(),
143 component_type: Some("rerun.components.Name".into()),
144 }
145 }
146
147 #[inline]
151 pub fn descriptor_visible_series() -> ComponentDescriptor {
152 ComponentDescriptor {
153 archetype: Some("rerun.archetypes.SeriesPoints".into()),
154 component: "SeriesPoints:visible_series".into(),
155 component_type: Some("rerun.components.SeriesVisible".into()),
156 }
157 }
158
159 #[inline]
163 pub fn descriptor_marker_sizes() -> ComponentDescriptor {
164 ComponentDescriptor {
165 archetype: Some("rerun.archetypes.SeriesPoints".into()),
166 component: "SeriesPoints:marker_sizes".into(),
167 component_type: Some("rerun.components.MarkerSize".into()),
168 }
169 }
170}
171
172static REQUIRED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 1usize]> =
173 once_cell::sync::Lazy::new(|| [SeriesPoints::descriptor_markers()]);
174
175static RECOMMENDED_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 0usize]> =
176 once_cell::sync::Lazy::new(|| []);
177
178static OPTIONAL_COMPONENTS: once_cell::sync::Lazy<[ComponentDescriptor; 4usize]> =
179 once_cell::sync::Lazy::new(|| {
180 [
181 SeriesPoints::descriptor_colors(),
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; 5usize]> =
189 once_cell::sync::Lazy::new(|| {
190 [
191 SeriesPoints::descriptor_markers(),
192 SeriesPoints::descriptor_colors(),
193 SeriesPoints::descriptor_names(),
194 SeriesPoints::descriptor_visible_series(),
195 SeriesPoints::descriptor_marker_sizes(),
196 ]
197 });
198
199impl SeriesPoints {
200 pub const NUM_COMPONENTS: usize = 5usize;
202}
203
204impl ::re_types_core::Archetype for SeriesPoints {
205 #[inline]
206 fn name() -> ::re_types_core::ArchetypeName {
207 "rerun.archetypes.SeriesPoints".into()
208 }
209
210 #[inline]
211 fn display_name() -> &'static str {
212 "Series points"
213 }
214
215 #[inline]
216 fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
217 REQUIRED_COMPONENTS.as_slice().into()
218 }
219
220 #[inline]
221 fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
222 RECOMMENDED_COMPONENTS.as_slice().into()
223 }
224
225 #[inline]
226 fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
227 OPTIONAL_COMPONENTS.as_slice().into()
228 }
229
230 #[inline]
231 fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
232 ALL_COMPONENTS.as_slice().into()
233 }
234
235 #[inline]
236 fn from_arrow_components(
237 arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
238 ) -> DeserializationResult<Self> {
239 re_tracing::profile_function!();
240 use ::re_types_core::{Loggable as _, ResultExt as _};
241 let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
242 let colors = arrays_by_descr
243 .get(&Self::descriptor_colors())
244 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_colors()));
245 let markers = arrays_by_descr
246 .get(&Self::descriptor_markers())
247 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_markers()));
248 let names = arrays_by_descr
249 .get(&Self::descriptor_names())
250 .map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_names()));
251 let visible_series = arrays_by_descr
252 .get(&Self::descriptor_visible_series())
253 .map(|array| {
254 SerializedComponentBatch::new(array.clone(), Self::descriptor_visible_series())
255 });
256 let marker_sizes = arrays_by_descr
257 .get(&Self::descriptor_marker_sizes())
258 .map(|array| {
259 SerializedComponentBatch::new(array.clone(), Self::descriptor_marker_sizes())
260 });
261 Ok(Self {
262 colors,
263 markers,
264 names,
265 visible_series,
266 marker_sizes,
267 })
268 }
269}
270
271impl ::re_types_core::AsComponents for SeriesPoints {
272 #[inline]
273 fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
274 use ::re_types_core::Archetype as _;
275 [
276 self.colors.clone(),
277 self.markers.clone(),
278 self.names.clone(),
279 self.visible_series.clone(),
280 self.marker_sizes.clone(),
281 ]
282 .into_iter()
283 .flatten()
284 .collect()
285 }
286}
287
288impl ::re_types_core::ArchetypeReflectionMarker for SeriesPoints {}
289
290impl SeriesPoints {
291 #[inline]
293 pub fn new() -> Self {
294 Self {
295 colors: None,
296 markers: None,
297 names: None,
298 visible_series: None,
299 marker_sizes: None,
300 }
301 }
302
303 #[inline]
305 pub fn update_fields() -> Self {
306 Self::default()
307 }
308
309 #[inline]
311 pub fn clear_fields() -> Self {
312 use ::re_types_core::Loggable as _;
313 Self {
314 colors: Some(SerializedComponentBatch::new(
315 crate::components::Color::arrow_empty(),
316 Self::descriptor_colors(),
317 )),
318 markers: Some(SerializedComponentBatch::new(
319 crate::components::MarkerShape::arrow_empty(),
320 Self::descriptor_markers(),
321 )),
322 names: Some(SerializedComponentBatch::new(
323 crate::components::Name::arrow_empty(),
324 Self::descriptor_names(),
325 )),
326 visible_series: Some(SerializedComponentBatch::new(
327 crate::components::SeriesVisible::arrow_empty(),
328 Self::descriptor_visible_series(),
329 )),
330 marker_sizes: Some(SerializedComponentBatch::new(
331 crate::components::MarkerSize::arrow_empty(),
332 Self::descriptor_marker_sizes(),
333 )),
334 }
335 }
336
337 #[inline]
348 pub fn columns<I>(
349 self,
350 _lengths: I,
351 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
352 where
353 I: IntoIterator<Item = usize> + Clone,
354 {
355 let columns = [
356 self.colors
357 .map(|colors| colors.partitioned(_lengths.clone()))
358 .transpose()?,
359 self.markers
360 .map(|markers| markers.partitioned(_lengths.clone()))
361 .transpose()?,
362 self.names
363 .map(|names| names.partitioned(_lengths.clone()))
364 .transpose()?,
365 self.visible_series
366 .map(|visible_series| visible_series.partitioned(_lengths.clone()))
367 .transpose()?,
368 self.marker_sizes
369 .map(|marker_sizes| marker_sizes.partitioned(_lengths.clone()))
370 .transpose()?,
371 ];
372 Ok(columns.into_iter().flatten())
373 }
374
375 #[inline]
380 pub fn columns_of_unit_batches(
381 self,
382 ) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
383 let len_colors = self.colors.as_ref().map(|b| b.array.len());
384 let len_markers = self.markers.as_ref().map(|b| b.array.len());
385 let len_names = self.names.as_ref().map(|b| b.array.len());
386 let len_visible_series = self.visible_series.as_ref().map(|b| b.array.len());
387 let len_marker_sizes = self.marker_sizes.as_ref().map(|b| b.array.len());
388 let len = None
389 .or(len_colors)
390 .or(len_markers)
391 .or(len_names)
392 .or(len_visible_series)
393 .or(len_marker_sizes)
394 .unwrap_or(0);
395 self.columns(std::iter::repeat(1).take(len))
396 }
397
398 #[inline]
402 pub fn with_colors(
403 mut self,
404 colors: impl IntoIterator<Item = impl Into<crate::components::Color>>,
405 ) -> Self {
406 self.colors = try_serialize_field(Self::descriptor_colors(), colors);
407 self
408 }
409
410 #[inline]
414 pub fn with_markers(
415 mut self,
416 markers: impl IntoIterator<Item = impl Into<crate::components::MarkerShape>>,
417 ) -> Self {
418 self.markers = try_serialize_field(Self::descriptor_markers(), markers);
419 self
420 }
421
422 #[inline]
426 pub fn with_names(
427 mut self,
428 names: impl IntoIterator<Item = impl Into<crate::components::Name>>,
429 ) -> Self {
430 self.names = try_serialize_field(Self::descriptor_names(), names);
431 self
432 }
433
434 #[inline]
442 pub fn with_visible_series(
443 mut self,
444 visible_series: impl IntoIterator<Item = impl Into<crate::components::SeriesVisible>>,
445 ) -> Self {
446 self.visible_series =
447 try_serialize_field(Self::descriptor_visible_series(), visible_series);
448 self
449 }
450
451 #[inline]
455 pub fn with_marker_sizes(
456 mut self,
457 marker_sizes: impl IntoIterator<Item = impl Into<crate::components::MarkerSize>>,
458 ) -> Self {
459 self.marker_sizes = try_serialize_field(Self::descriptor_marker_sizes(), marker_sizes);
460 self
461 }
462}
463
464impl ::re_byte_size::SizeBytes for SeriesPoints {
465 #[inline]
466 fn heap_size_bytes(&self) -> u64 {
467 self.colors.heap_size_bytes()
468 + self.markers.heap_size_bytes()
469 + self.names.heap_size_bytes()
470 + self.visible_series.heap_size_bytes()
471 + self.marker_sizes.heap_size_bytes()
472 }
473}