#![allow(unused_braces)]
#![allow(unused_imports)]
#![allow(unused_parens)]
#![allow(clippy::allow_attributes)]
#![allow(clippy::clone_on_copy)]
#![allow(clippy::cloned_instead_of_copied)]
#![allow(clippy::map_flatten)]
#![allow(clippy::needless_question_mark)]
#![allow(clippy::new_without_default)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::wildcard_imports)]
use ::re_types_core::SerializationResult;
use ::re_types_core::try_serialize_field;
use ::re_types_core::{ComponentBatch as _, SerializedComponentBatch};
use ::re_types_core::{ComponentDescriptor, ComponentType};
use ::re_types_core::{DeserializationError, DeserializationResult};
#[derive(Clone, Debug, PartialEq, Default)]
pub struct Scalars {
pub scalars: Option<SerializedComponentBatch>,
}
impl Scalars {
#[inline]
pub fn descriptor_scalars() -> ComponentDescriptor {
ComponentDescriptor {
archetype: Some("rerun.archetypes.Scalars".into()),
component: "Scalars:scalars".into(),
component_type: Some("rerun.components.Scalar".into()),
}
}
}
static REQUIRED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
std::sync::LazyLock::new(|| [Scalars::descriptor_scalars()]);
static RECOMMENDED_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 0usize]> =
std::sync::LazyLock::new(|| []);
static OPTIONAL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 0usize]> =
std::sync::LazyLock::new(|| []);
static ALL_COMPONENTS: std::sync::LazyLock<[ComponentDescriptor; 1usize]> =
std::sync::LazyLock::new(|| [Scalars::descriptor_scalars()]);
impl Scalars {
pub const NUM_COMPONENTS: usize = 1usize;
}
impl ::re_types_core::Archetype for Scalars {
#[inline]
fn name() -> ::re_types_core::ArchetypeName {
"rerun.archetypes.Scalars".into()
}
#[inline]
fn display_name() -> &'static str {
"Scalars"
}
#[inline]
fn required_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
REQUIRED_COMPONENTS.as_slice().into()
}
#[inline]
fn recommended_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
RECOMMENDED_COMPONENTS.as_slice().into()
}
#[inline]
fn optional_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
OPTIONAL_COMPONENTS.as_slice().into()
}
#[inline]
fn all_components() -> ::std::borrow::Cow<'static, [ComponentDescriptor]> {
ALL_COMPONENTS.as_slice().into()
}
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (ComponentDescriptor, arrow::array::ArrayRef)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();
use ::re_types_core::{Loggable as _, ResultExt as _};
let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();
let scalars = arrays_by_descr
.get(&Self::descriptor_scalars())
.map(|array| SerializedComponentBatch::new(array.clone(), Self::descriptor_scalars()));
Ok(Self { scalars })
}
}
impl ::re_types_core::AsComponents for Scalars {
#[inline]
fn as_serialized_batches(&self) -> Vec<SerializedComponentBatch> {
use ::re_types_core::Archetype as _;
std::iter::once(self.scalars.clone()).flatten().collect()
}
}
impl ::re_types_core::ArchetypeReflectionMarker for Scalars {}
impl Scalars {
#[inline]
pub fn new(scalars: impl IntoIterator<Item = impl Into<crate::components::Scalar>>) -> Self {
Self {
scalars: try_serialize_field(Self::descriptor_scalars(), scalars),
}
}
#[inline]
pub fn update_fields() -> Self {
Self::default()
}
#[inline]
pub fn clear_fields() -> Self {
use ::re_types_core::Loggable as _;
Self {
scalars: Some(SerializedComponentBatch::new(
crate::components::Scalar::arrow_empty(),
Self::descriptor_scalars(),
)),
}
}
#[inline]
pub fn columns<I>(
self,
_lengths: I,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>>
where
I: IntoIterator<Item = usize> + Clone,
{
let columns = [self
.scalars
.map(|scalars| scalars.partitioned(_lengths.clone()))
.transpose()?];
Ok(columns.into_iter().flatten())
}
#[inline]
pub fn columns_of_unit_batches(
self,
) -> SerializationResult<impl Iterator<Item = ::re_types_core::SerializedComponentColumn>> {
let len_scalars = self.scalars.as_ref().map(|b| b.array.len());
let len = None.or(len_scalars).unwrap_or(0);
self.columns(std::iter::repeat_n(1, len))
}
#[inline]
pub fn with_scalars(
mut self,
scalars: impl IntoIterator<Item = impl Into<crate::components::Scalar>>,
) -> Self {
self.scalars = try_serialize_field(Self::descriptor_scalars(), scalars);
self
}
}
impl ::re_byte_size::SizeBytes for Scalars {
#[inline]
fn heap_size_bytes(&self) -> u64 {
self.scalars.heap_size_bytes()
}
}