From c727698fc869ed35d4dc1dc6b3a414503ed07cd3 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Wed, 28 Jun 2023 11:15:04 +0200 Subject: [PATCH] wip --- _typos.toml | 7 +- .../definitions/rerun/archetypes/points2d.fbs | 1 - crates/re_types/source_hash.txt | 2 +- crates/re_types/src/archetypes/fuzzy.rs | 851 +++++- crates/re_types/src/archetypes/points2d.rs | 270 +- crates/re_types/src/components/class_id.rs | 64 + crates/re_types/src/components/color.rs | 64 + crates/re_types/src/components/draw_order.rs | 64 + crates/re_types/src/components/fuzzy.rs | 2440 +++++++++++++++++ .../re_types/src/components/instance_key.rs | 64 + crates/re_types/src/components/keypoint_id.rs | 64 + crates/re_types/src/components/label.rs | 79 + crates/re_types/src/components/point2d.rs | 208 ++ crates/re_types/src/components/radius.rs | 64 + crates/re_types/src/datatypes/fuzzy.rs | 971 +++++++ crates/re_types/src/datatypes/vec2d.rs | 158 ++ crates/re_types/src/lib.rs | 193 ++ crates/re_types/tests/fuzzy.rs | 14 +- crates/re_types/tests/points2d.rs | 32 +- crates/re_types_builder/src/codegen/rust.rs | 756 ++++- crates/re_types_builder/src/lib.rs | 2 +- scripts/check_large_files_allow_list.txt | 1 + 22 files changed, 6336 insertions(+), 33 deletions(-) diff --git a/_typos.toml b/_typos.toml index c943f61426b5..adb9d5b658d4 100644 --- a/_typos.toml +++ b/_typos.toml @@ -11,9 +11,10 @@ extend-exclude = [ [default.extend-words] -lod = "lod" # level-of-detail -teh = "teh" # part of @teh-cmc -ND = "ND" # np.NDArray +lod = "lod" # level-of-detail +teh = "teh" # part of @teh-cmc +ND = "ND" # np.NDArray +somes = "somes" # many `Some` # American English: grey = "gray" diff --git a/crates/re_types/definitions/rerun/archetypes/points2d.fbs b/crates/re_types/definitions/rerun/archetypes/points2d.fbs index a483faa3aae5..d4c16c1712e2 100644 --- a/crates/re_types/definitions/rerun/archetypes/points2d.fbs +++ b/crates/re_types/definitions/rerun/archetypes/points2d.fbs @@ -1,6 +1,5 @@ include "fbs/attributes.fbs"; -include "rerun/datatypes.fbs"; include "rerun/components.fbs"; namespace rerun.archetypes; diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 5e7d17b92edd..14ac8af3b840 100644 --- a/crates/re_types/source_hash.txt +++ b/crates/re_types/source_hash.txt @@ -1,4 +1,4 @@ # This is a sha256 hash for all direct and indirect dependencies of this crate's build script. # It can be safely removed at anytime to force the build script to run again. # Check out build.rs to see how it's computed. -48d4a7434f8d1ea619b3974d65d67f76ca56f7a49ca7f683e5245814d81bf524 +87352caf7669e28dcadfc378ef216fc82955662656f2908cec2b961d91ff934f \ No newline at end of file diff --git a/crates/re_types/src/archetypes/fuzzy.rs b/crates/re_types/src/archetypes/fuzzy.rs index a4cb29782f0b..6750b5887290 100644 --- a/crates/re_types/src/archetypes/fuzzy.rs +++ b/crates/re_types/src/archetypes/fuzzy.rs @@ -110,25 +110,870 @@ impl AffixFuzzer1 { } impl crate::Archetype for AffixFuzzer1 { + #[inline] fn name() -> crate::ArchetypeName { crate::ArchetypeName::Borrowed("rerun.testing.archetypes.AffixFuzzer1") } + #[inline] fn required_components() -> Vec { Self::REQUIRED_COMPONENTS.to_vec() } + #[inline] fn recommended_components() -> Vec { Self::RECOMMENDED_COMPONENTS.to_vec() } + #[inline] fn optional_components() -> Vec { Self::OPTIONAL_COMPONENTS.to_vec() } - #[allow(clippy::todo)] - fn to_arrow_datatypes() -> Vec { - todo!("query the registry for all fqnames"); + #[inline] + fn try_to_arrow( + &self, + ) -> crate::SerializationResult< + Vec<(::arrow2::datatypes::Field, Box)>, + > { + use crate::Component as _; + Ok([ + { + Some({ + let array = ::try_to_arrow([&self.fuzz1001]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1001", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1002]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1002", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1003]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1003", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1004]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1004", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1005]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1005", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1006]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1006", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow([&self.fuzz1007]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1007", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1101.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1101", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1102.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1102", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1103.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1103", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1104.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1104", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1105.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1105", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1106.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1106", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow(self.fuzz1107.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz1107", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2001 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2001", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2002 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2002", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2003 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2003", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2004 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2004", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2005 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2005", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2006 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2006", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2007 + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2007", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2101 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2101", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2102 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2102", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2103 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2103", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2104 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2104", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2105 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2105", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2106 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2106", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2107 + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("fuzz2107", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + ] + .into_iter() + .flatten() + .collect()) + } + + #[inline] + fn try_from_arrow( + data: impl IntoIterator)>, + ) -> crate::DeserializationResult { + use crate::Component as _; + let arrays_by_name: ::std::collections::HashMap<_, _> = data + .into_iter() + .map(|(field, array)| (field.name, array)) + .collect(); + let fuzz1001 = { + let array = arrays_by_name.get("fuzz1001").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1002 = { + let array = arrays_by_name.get("fuzz1002").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1003 = { + let array = arrays_by_name.get("fuzz1003").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1004 = { + let array = arrays_by_name.get("fuzz1004").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1005 = { + let array = arrays_by_name.get("fuzz1005").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1006 = { + let array = arrays_by_name.get("fuzz1006").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1007 = { + let array = arrays_by_name.get("fuzz1007").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })? + }; + let fuzz1101 = { + let array = arrays_by_name.get("fuzz1101").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1102 = { + let array = arrays_by_name.get("fuzz1102").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1103 = { + let array = arrays_by_name.get("fuzz1103").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1104 = { + let array = arrays_by_name.get("fuzz1104").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1105 = { + let array = arrays_by_name.get("fuzz1105").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1106 = { + let array = arrays_by_name.get("fuzz1106").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz1107 = { + let array = arrays_by_name.get("fuzz1107").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let fuzz2001 = if let Some(array) = arrays_by_name.get("fuzz2001") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2002 = if let Some(array) = arrays_by_name.get("fuzz2002") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2003 = if let Some(array) = arrays_by_name.get("fuzz2003") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2004 = if let Some(array) = arrays_by_name.get("fuzz2004") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2005 = if let Some(array) = arrays_by_name.get("fuzz2005") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2006 = if let Some(array) = arrays_by_name.get("fuzz2006") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2007 = if let Some(array) = arrays_by_name.get("fuzz2007") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2101 = if let Some(array) = arrays_by_name.get("fuzz2101") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2102 = if let Some(array) = arrays_by_name.get("fuzz2102") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2103 = if let Some(array) = arrays_by_name.get("fuzz2103") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2104 = if let Some(array) = arrays_by_name.get("fuzz2104") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2105 = if let Some(array) = arrays_by_name.get("fuzz2105") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2106 = if let Some(array) = arrays_by_name.get("fuzz2106") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let fuzz2107 = if let Some(array) = arrays_by_name.get("fuzz2107") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + Ok(Self { + fuzz1001, + fuzz1002, + fuzz1003, + fuzz1004, + fuzz1005, + fuzz1006, + fuzz1007, + fuzz1101, + fuzz1102, + fuzz1103, + fuzz1104, + fuzz1105, + fuzz1106, + fuzz1107, + fuzz2001, + fuzz2002, + fuzz2003, + fuzz2004, + fuzz2005, + fuzz2006, + fuzz2007, + fuzz2101, + fuzz2102, + fuzz2103, + fuzz2104, + fuzz2105, + fuzz2106, + fuzz2107, + }) } } diff --git a/crates/re_types/src/archetypes/points2d.rs b/crates/re_types/src/archetypes/points2d.rs index b3e03ac72e49..777e980a339a 100644 --- a/crates/re_types/src/archetypes/points2d.rs +++ b/crates/re_types/src/archetypes/points2d.rs @@ -78,25 +78,289 @@ impl Points2D { } impl crate::Archetype for Points2D { + #[inline] fn name() -> crate::ArchetypeName { crate::ArchetypeName::Borrowed("rerun.archetypes.Points2D") } + #[inline] fn required_components() -> Vec { Self::REQUIRED_COMPONENTS.to_vec() } + #[inline] fn recommended_components() -> Vec { Self::RECOMMENDED_COMPONENTS.to_vec() } + #[inline] fn optional_components() -> Vec { Self::OPTIONAL_COMPONENTS.to_vec() } - #[allow(clippy::todo)] - fn to_arrow_datatypes() -> Vec { - todo!("query the registry for all fqnames"); + #[inline] + fn try_to_arrow( + &self, + ) -> crate::SerializationResult< + Vec<(::arrow2::datatypes::Field, Box)>, + > { + use crate::Component as _; + Ok([ + { + Some({ + let array = ::try_to_arrow(self.points.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("points", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.radii + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("radii", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.colors + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("colors", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.labels + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("labels", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.draw_order + .as_ref() + .map(|single| { + let array = ::try_to_arrow([single]); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("draw_order", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.class_ids + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("class_ids", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.keypoint_ids + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("keypoint_ids", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.instance_keys + .as_ref() + .map(|many| { + let array = ::try_to_arrow(many.iter()); + array.map(|array| { + let datatype = array.data_type().clone(); + ( + ::arrow2::datatypes::Field::new("instance_keys", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + ] + .into_iter() + .flatten() + .collect()) + } + + #[inline] + fn try_from_arrow( + data: impl IntoIterator)>, + ) -> crate::DeserializationResult { + use crate::Component as _; + let arrays_by_name: ::std::collections::HashMap<_, _> = data + .into_iter() + .map(|(field, array)| (field.name, array)) + .collect(); + let points = { + let array = arrays_by_name.get("points").ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + } + })?; + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()? + }; + let radii = if let Some(array) = arrays_by_name.get("radii") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let colors = if let Some(array) = arrays_by_name.get("colors") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let labels = if let Some(array) = arrays_by_name.get("labels") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let draw_order = if let Some(array) = arrays_by_name.get("draw_order") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let class_ids = if let Some(array) = arrays_by_name.get("class_ids") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let keypoint_ids = if let Some(array) = arrays_by_name.get("keypoint_ids") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + let instance_keys = if let Some(array) = arrays_by_name.get("instance_keys") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + }) + }) + .collect::>>()?, + ) + } else { + None + }; + Ok(Self { + points, + radii, + colors, + labels, + draw_order, + class_ids, + keypoint_ids, + instance_keys, + }) } } diff --git a/crates/re_types/src/components/class_id.rs b/crates/re_types/src/components/class_id.rs index d12f2168d5a5..a919d261aee8 100644 --- a/crates/re_types/src/components/class_id.rs +++ b/crates/re_types/src/components/class_id.rs @@ -15,12 +15,14 @@ pub struct ClassId(pub u16); impl<'a> From for ::std::borrow::Cow<'a, ClassId> { + #[inline] fn from(value: ClassId) -> Self { std::borrow::Cow::Owned(value) } } impl<'a> From<&'a ClassId> for ::std::borrow::Cow<'a, ClassId> { + #[inline] fn from(value: &'a ClassId) -> Self { std::borrow::Cow::Borrowed(value) } @@ -42,4 +44,66 @@ impl crate::Component for ClassId { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::UInt16, + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.components.ClassId".to_owned(), + Box::new(DataType::UInt16), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } diff --git a/crates/re_types/src/components/color.rs b/crates/re_types/src/components/color.rs index fa79223519e4..ca6ae6cd403d 100644 --- a/crates/re_types/src/components/color.rs +++ b/crates/re_types/src/components/color.rs @@ -25,12 +25,14 @@ pub struct Color(pub u32); impl<'a> From for ::std::borrow::Cow<'a, Color> { + #[inline] fn from(value: Color) -> Self { std::borrow::Cow::Owned(value) } } impl<'a> From<&'a Color> for ::std::borrow::Cow<'a, Color> { + #[inline] fn from(value: &'a Color) -> Self { std::borrow::Cow::Borrowed(value) } @@ -52,4 +54,66 @@ impl crate::Component for Color { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::UInt32, + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.components.Color".to_owned(), + Box::new(DataType::UInt32), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } diff --git a/crates/re_types/src/components/draw_order.rs b/crates/re_types/src/components/draw_order.rs index 3b2a080f87b4..b97a818dac38 100644 --- a/crates/re_types/src/components/draw_order.rs +++ b/crates/re_types/src/components/draw_order.rs @@ -20,12 +20,14 @@ pub struct DrawOrder(pub f32); impl<'a> From for ::std::borrow::Cow<'a, DrawOrder> { + #[inline] fn from(value: DrawOrder) -> Self { std::borrow::Cow::Owned(value) } } impl<'a> From<&'a DrawOrder> for ::std::borrow::Cow<'a, DrawOrder> { + #[inline] fn from(value: &'a DrawOrder) -> Self { std::borrow::Cow::Borrowed(value) } @@ -47,4 +49,66 @@ impl crate::Component for DrawOrder { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::Float32, + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.components.DrawOrder".to_owned(), + Box::new(DataType::Float32), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } diff --git a/crates/re_types/src/components/fuzzy.rs b/crates/re_types/src/components/fuzzy.rs index f977e38fefd5..0c48d75fc572 100644 --- a/crates/re_types/src/components/fuzzy.rs +++ b/crates/re_types/src/components/fuzzy.rs @@ -13,6 +13,20 @@ pub struct AffixFuzzer1 { pub single_required: crate::datatypes::AffixFuzzer1, } +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer1> { + #[inline] + fn from(value: AffixFuzzer1) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer1> for ::std::borrow::Cow<'a, AffixFuzzer1> { + #[inline] + fn from(value: &'a AffixFuzzer1) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer1 { #[inline] fn name() -> crate::ComponentName { @@ -85,11 +99,137 @@ impl crate::Component for AffixFuzzer1 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, single_required): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self { single_required } = datum.into_owned(); + single_required + }); + (datum.is_some(), datum) + }) + .unzip(); + let single_required_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = single_required_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(single_required)? + } + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.components.AffixFuzzer1".to_owned(), + Box::new(DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + )), + None, + ), + }) + }) + .map(|res| res.map(|single_required| Some(Self { single_required }))) + .collect::>>>()?) + } } #[derive(Debug, Clone, PartialEq)] pub struct AffixFuzzer2(pub crate::datatypes::AffixFuzzer1); +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer2> { + #[inline] + fn from(value: AffixFuzzer2) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer2> for ::std::borrow::Cow<'a, AffixFuzzer2> { + #[inline] + fn from(value: &'a AffixFuzzer2) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer2 { #[inline] fn name() -> crate::ComponentName { @@ -162,6 +302,118 @@ impl crate::Component for AffixFuzzer2 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = data0_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(data0)? + } + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.components.AffixFuzzer2".to_owned(), + Box::new(DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + )), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } #[derive(Debug, Clone, PartialEq)] @@ -169,6 +421,20 @@ pub struct AffixFuzzer3 { pub single_required: crate::datatypes::AffixFuzzer1, } +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer3> { + #[inline] + fn from(value: AffixFuzzer3) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer3> for ::std::borrow::Cow<'a, AffixFuzzer3> { + #[inline] + fn from(value: &'a AffixFuzzer3) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer3 { #[inline] fn name() -> crate::ComponentName { @@ -246,6 +512,313 @@ impl crate::Component for AffixFuzzer3 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + StructArray::new( + DataType::Extension( + "rerun.testing.components.AffixFuzzer3".to_owned(), + Box::new(DataType::Struct(vec![Field { + name: "single_required".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: false, + metadata: [].into(), + }])), + None, + ), + vec![{ + let (somes, single_required): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| { + let Self { + single_required, .. + } = &**datum; + single_required.clone() + }); + (datum.is_some(), datum) + }) + .unzip(); + let single_required_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = single_required_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(single_required)? + } + }], + bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let data = data + .as_any() + .downcast_ref::<::arrow2::array::StructArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: DataType::Extension( + "rerun.testing.components.AffixFuzzer3".to_owned(), + Box::new(DataType::Struct(vec![Field { + name: "single_required".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: false, + metadata: [].into(), + }])), + None, + ), + got: data.data_type().clone(), + })?; + let (data_fields, data_arrays, data_bitmap) = + (data.fields(), data.values(), data.validity()); + let is_valid = |i| data_bitmap.map_or(true, |bitmap| bitmap.get_bit(i)); + let arrays_by_name: ::std::collections::HashMap<_, _> = data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(data_arrays) + .collect(); + let single_required = { + let data = &**arrays_by_name["single_required"]; + + crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)?.into_iter() + }; + ::itertools::izip!(single_required) + .enumerate() + .map(|(i, (single_required))| { + is_valid(i) + .then(|| { + Ok(Self { + single_required: single_required.ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.components.AffixFuzzer3".to_owned(), + Box::new(DataType::Struct(vec![Field { + name: "single_required".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1" + .to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional" + .to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new( + Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + )), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required" + .to_owned(), + data_type: DataType::List(Box::new( + Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + )), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional" + .to_owned(), + data_type: DataType::List(Box::new( + Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + )), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: false, + metadata: [].into(), + }])), + None, + ), + } + })?, + }) + }) + .transpose() + }) + .collect::>>()? + }) + } } #[derive(Debug, Clone, PartialEq)] @@ -253,6 +826,20 @@ pub struct AffixFuzzer4 { pub single_optional: Option, } +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer4> { + #[inline] + fn from(value: AffixFuzzer4) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer4> for ::std::borrow::Cow<'a, AffixFuzzer4> { + #[inline] + fn from(value: &'a AffixFuzzer4) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer4 { #[inline] fn name() -> crate::ComponentName { @@ -325,11 +912,75 @@ impl crate::Component for AffixFuzzer4 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, single_optional): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum + .map(|datum| { + let Self { single_optional } = datum.into_owned(); + single_optional + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let single_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = single_optional_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(single_optional)? + } + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)? + .into_iter() + .map(Ok) + .map(|res| res.map(|single_optional| Some(Self { single_optional }))) + .collect::>>>()?) + } } #[derive(Debug, Clone, PartialEq)] pub struct AffixFuzzer5(pub Option); +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer5> { + #[inline] + fn from(value: AffixFuzzer5) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer5> for ::std::borrow::Cow<'a, AffixFuzzer5> { + #[inline] + fn from(value: &'a AffixFuzzer5) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer5 { #[inline] fn name() -> crate::ComponentName { @@ -402,6 +1053,56 @@ impl crate::Component for AffixFuzzer5 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum + .map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = data0_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(data0)? + } + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)? + .into_iter() + .map(Ok) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } #[derive(Debug, Clone, PartialEq)] @@ -409,6 +1110,20 @@ pub struct AffixFuzzer6 { pub single_optional: Option, } +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer6> { + #[inline] + fn from(value: AffixFuzzer6) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer6> for ::std::borrow::Cow<'a, AffixFuzzer6> { + #[inline] + fn from(value: &'a AffixFuzzer6) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer6 { #[inline] fn name() -> crate::ComponentName { @@ -486,6 +1201,231 @@ impl crate::Component for AffixFuzzer6 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + StructArray::new( + DataType::Extension( + "rerun.testing.components.AffixFuzzer6".to_owned(), + Box::new(DataType::Struct(vec![Field { + name: "single_optional".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + }])), + None, + ), + vec![{ + let (somes, single_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { + single_optional, .. + } = &**datum; + single_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let single_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = single_optional_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt(single_optional)? + } + }], + bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let data = data + .as_any() + .downcast_ref::<::arrow2::array::StructArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: DataType::Extension( + "rerun.testing.components.AffixFuzzer6".to_owned(), + Box::new(DataType::Struct(vec![Field { + name: "single_optional".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + }])), + None, + ), + got: data.data_type().clone(), + })?; + let (data_fields, data_arrays, data_bitmap) = + (data.fields(), data.values(), data.validity()); + let is_valid = |i| data_bitmap.map_or(true, |bitmap| bitmap.get_bit(i)); + let arrays_by_name: ::std::collections::HashMap<_, _> = data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(data_arrays) + .collect(); + let single_optional = { + let data = &**arrays_by_name["single_optional"]; + + crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)?.into_iter() + }; + ::itertools::izip!(single_optional) + .enumerate() + .map(|(i, (single_optional))| { + is_valid(i) + .then(|| Ok(Self { single_optional })) + .transpose() + }) + .collect::>>()? + }) + } } #[derive(Debug, Clone, PartialEq)] @@ -499,6 +1439,20 @@ pub struct AffixFuzzer7 { pub many_strings_optional: Option>, } +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer7> { + #[inline] + fn from(value: AffixFuzzer7) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer7> for ::std::borrow::Cow<'a, AffixFuzzer7> { + #[inline] + fn from(value: &'a AffixFuzzer7) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + impl crate::Component for AffixFuzzer7 { #[inline] fn name() -> crate::ComponentName { @@ -634,4 +1588,1490 @@ impl crate::Component for AffixFuzzer7 { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + (datum.is_some(), datum) + }) + .unzip(); + let bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + StructArray::new( + DataType::Extension( + "rerun.testing.components.AffixFuzzer7".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + vec![ + { + let (somes, many_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { many_optional, .. } = &**datum; + many_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let many_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let many_optional_inner_data: Vec<_> = many_optional + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_optional_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = + many_optional_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_optional_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_optional.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + offsets, + { + _ = many_optional_inner_bitmap; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt( + many_optional_inner_data, + )? + }, + many_optional_bitmap, + ) + .boxed() + } + }, + { + let (somes, single_float_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { + single_float_optional, + .. + } = &**datum; + single_float_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let single_float_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::Float32, + single_float_optional + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect(), + single_float_optional_bitmap, + ) + .boxed() + }, + { + let (somes, single_string_required): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| { + let Self { + single_string_required, + .. + } = &**datum; + single_string_required.clone() + }); + (datum.is_some(), datum) + }) + .unzip(); + let single_string_required_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + let inner_data: ::arrow2::buffer::Buffer = single_string_required + .iter() + .flatten() + .flat_map(|s| s.bytes()) + .collect(); + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + single_string_required.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + unsafe { + Utf8Array::::new_unchecked( + DataType::Utf8, + offsets, + inner_data, + single_string_required_bitmap, + ) + } + .boxed() + } + }, + { + let (somes, single_string_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { + single_string_optional, + .. + } = &**datum; + single_string_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let single_string_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + let inner_data: ::arrow2::buffer::Buffer = single_string_optional + .iter() + .flatten() + .flat_map(|s| s.bytes()) + .collect(); + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + single_string_optional.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + unsafe { + Utf8Array::::new_unchecked( + DataType::Utf8, + offsets, + inner_data, + single_string_optional_bitmap, + ) + } + .boxed() + } + }, + { + let (somes, many_floats_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { + many_floats_optional, + .. + } = &**datum; + many_floats_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let many_floats_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let many_floats_optional_inner_data: Vec<_> = many_floats_optional + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_floats_optional_inner_bitmap: Option< + ::arrow2::bitmap::Bitmap, + > = { + let any_nones = + many_floats_optional_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_floats_optional_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_floats_optional.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + offsets, + PrimitiveArray::new( + DataType::Float32, + many_floats_optional_inner_data + .into_iter() + .map(|v| v.unwrap_or_default()) + .collect(), + many_floats_optional_inner_bitmap, + ) + .boxed(), + many_floats_optional_bitmap, + ) + .boxed() + } + }, + { + let (somes, many_strings_required): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum.as_ref().map(|datum| { + let Self { + many_strings_required, + .. + } = &**datum; + many_strings_required.clone() + }); + (datum.is_some(), datum) + }) + .unzip(); + let many_strings_required_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let many_strings_required_inner_data: Vec<_> = many_strings_required + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_strings_required_inner_bitmap: Option< + ::arrow2::bitmap::Bitmap, + > = { + let any_nones = + many_strings_required_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_strings_required_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_strings_required.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + offsets, + { + let inner_data: ::arrow2::buffer::Buffer = + many_strings_required_inner_data + .iter() + .flatten() + .flat_map(|s| s.bytes()) + .collect(); + let offsets = + ::arrow2::offset::Offsets::::try_from_lengths( + many_strings_required_inner_data.iter().map(|opt| { + opt.as_ref() + .map(|datum| datum.len()) + .unwrap_or_default() + }), + ) + .unwrap() + .into(); + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + unsafe { + Utf8Array::::new_unchecked( + DataType::Utf8, + offsets, + inner_data, + many_strings_required_inner_bitmap, + ) + } + .boxed() + }, + many_strings_required_bitmap, + ) + .boxed() + } + }, + { + let (somes, many_strings_optional): (Vec<_>, Vec<_>) = data + .iter() + .map(|datum| { + let datum = datum + .as_ref() + .map(|datum| { + let Self { + many_strings_optional, + .. + } = &**datum; + many_strings_optional.clone() + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let many_strings_optional_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let many_strings_optional_inner_data: Vec<_> = many_strings_optional + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_strings_optional_inner_bitmap: Option< + ::arrow2::bitmap::Bitmap, + > = { + let any_nones = + many_strings_optional_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_strings_optional_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_strings_optional.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + offsets, + { + let inner_data: ::arrow2::buffer::Buffer = + many_strings_optional_inner_data + .iter() + .flatten() + .flat_map(|s| s.bytes()) + .collect(); + let offsets = + ::arrow2::offset::Offsets::::try_from_lengths( + many_strings_optional_inner_data.iter().map(|opt| { + opt.as_ref() + .map(|datum| datum.len()) + .unwrap_or_default() + }), + ) + .unwrap() + .into(); + #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] + unsafe { + Utf8Array::::new_unchecked( + DataType::Utf8, + offsets, + inner_data, + many_strings_optional_inner_bitmap, + ) + } + .boxed() + }, + many_strings_optional_bitmap, + ) + .boxed() + } + }, + ], + bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let data = data + .as_any() + .downcast_ref::<::arrow2::array::StructArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: DataType::Extension( + "rerun.testing.components.AffixFuzzer7".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + got: data.data_type().clone(), + })?; + let (data_fields, data_arrays, data_bitmap) = + (data.fields(), data.values(), data.validity()); + let is_valid = |i| data_bitmap.map_or(true, |bitmap| bitmap.get_bit(i)); + let arrays_by_name: ::std::collections::HashMap<_, _> = data_fields + .iter() + .map(|field| field.name.as_str()) + .zip(data_arrays) + .collect(); + let many_optional = { + let data = &**arrays_by_name["many_optional"]; + + { + let data = data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .unwrap(); + let bitmap = data.validity().cloned(); + let offsets = { + let offsets = data.offsets(); + offsets.iter().copied().zip(offsets.iter().copied().skip(1)) + }; + let data = &**data.values(); + let data = crate::datatypes::AffixFuzzer1::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + }) + }) + .collect::>>()?; + offsets + .enumerate() + .map(move |(i, (start, end))| { + bitmap + .as_ref() + .map_or(true, |bitmap| bitmap.get_bit(i)) + .then(|| { + Ok(data + .get(start as usize..end as usize) + .ok_or_else(|| { + crate::DeserializationError::OffsetsMismatch { + bounds: (start as usize, end as usize), + len: data.len(), + datatype: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1" + .to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional" + .to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Float32, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }), + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + }; + let single_float_optional = { + let data = &**arrays_by_name["single_float_optional"]; + + data.as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + }; + let single_string_required = { + let data = &**arrays_by_name["single_string_required"]; + + data.as_any() + .downcast_ref::>() + .unwrap() + .into_iter() + .map(|v| v.map(ToOwned::to_owned)) + }; + let single_string_optional = { + let data = &**arrays_by_name["single_string_optional"]; + + data.as_any() + .downcast_ref::>() + .unwrap() + .into_iter() + .map(|v| v.map(ToOwned::to_owned)) + }; + let many_floats_optional = { + let data = &**arrays_by_name["many_floats_optional"]; + + { + let data = data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .unwrap(); + let bitmap = data.validity().cloned(); + let offsets = { + let offsets = data.offsets(); + offsets.iter().copied().zip(offsets.iter().copied().skip(1)) + }; + let data = &**data.values(); + let data = data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Float32, + }) + }) + .collect::>>()?; + offsets + .enumerate() + .map(move |(i, (start, end))| { + bitmap + .as_ref() + .map_or(true, |bitmap| bitmap.get_bit(i)) + .then(|| { + Ok(data + .get(start as usize..end as usize) + .ok_or_else(|| { + crate::DeserializationError::OffsetsMismatch { + bounds: (start as usize, end as usize), + len: data.len(), + datatype: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + }; + let many_strings_required = { + let data = &**arrays_by_name["many_strings_required"]; + + { + let data = data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .unwrap(); + let bitmap = data.validity().cloned(); + let offsets = { + let offsets = data.offsets(); + offsets.iter().copied().zip(offsets.iter().copied().skip(1)) + }; + let data = &**data.values(); + let data = data + .as_any() + .downcast_ref::>() + .unwrap() + .into_iter() + .map(|v| v.map(ToOwned::to_owned)) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Utf8, + }) + }) + .collect::>>()?; + offsets + .enumerate() + .map(move |(i, (start, end))| { + bitmap + .as_ref() + .map_or(true, |bitmap| bitmap.get_bit(i)) + .then(|| { + Ok(data + .get(start as usize..end as usize) + .ok_or_else(|| { + crate::DeserializationError::OffsetsMismatch { + bounds: (start as usize, end as usize), + len: data.len(), + datatype: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + }; + let many_strings_optional = { + let data = &**arrays_by_name["many_strings_optional"]; + + { + let data = data + .as_any() + .downcast_ref::<::arrow2::array::ListArray>() + .unwrap(); + let bitmap = data.validity().cloned(); + let offsets = { + let offsets = data.offsets(); + offsets.iter().copied().zip(offsets.iter().copied().skip(1)) + }; + let data = &**data.values(); + let data = data + .as_any() + .downcast_ref::>() + .unwrap() + .into_iter() + .map(|v| v.map(ToOwned::to_owned)) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Utf8, + }) + }) + .collect::>>()?; + offsets + .enumerate() + .map(move |(i, (start, end))| { + bitmap + .as_ref() + .map_or(true, |bitmap| bitmap.get_bit(i)) + .then(|| { + Ok(data + .get(start as usize..end as usize) + .ok_or_else(|| { + crate::DeserializationError::OffsetsMismatch { + bounds: (start as usize, end as usize), + len: data.len(), + datatype: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + }; + ::itertools::izip!( + many_optional, + single_float_optional, + single_string_required, + single_string_optional, + many_floats_optional, + many_strings_required, + many_strings_optional + ) + .enumerate() + .map( + |( + i, + ( + many_optional, + single_float_optional, + single_string_required, + single_string_optional, + many_floats_optional, + many_strings_required, + many_strings_optional, + ), + )| { + is_valid(i) + .then(|| { + Ok(Self { + many_optional, + single_float_optional, + single_string_required: single_string_required.ok_or_else( + || crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.components.AffixFuzzer7".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1" + .to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional" + .to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Float32, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }), + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + }, + )?, + single_string_optional, + many_floats_optional, + many_strings_required: many_strings_required.ok_or_else(|| { + crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.testing.components.AffixFuzzer7".to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Extension( + "rerun.testing.datatypes.AffixFuzzer1" + .to_owned(), + Box::new(DataType::Struct(vec![ + Field { + name: "single_float_optional" + .to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional" + .to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Float32, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }), + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional" + .to_owned(), + data_type: DataType::List( + Box::new(Field { + name: "item".to_owned(), + data_type: + DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }), + ), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_float_optional".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "single_string_required".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "single_string_optional".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_floats_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Float32, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + Field { + name: "many_strings_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_strings_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Utf8, + is_nullable: true, + metadata: [].into(), + })), + is_nullable: true, + metadata: [].into(), + }, + ])), + None, + ), + } + })?, + many_strings_optional, + }) + }) + .transpose() + }, + ) + .collect::>>()? + }) + } } diff --git a/crates/re_types/src/components/instance_key.rs b/crates/re_types/src/components/instance_key.rs index 399749094354..feb8939dc39e 100644 --- a/crates/re_types/src/components/instance_key.rs +++ b/crates/re_types/src/components/instance_key.rs @@ -13,12 +13,14 @@ pub struct InstanceKey(pub u64); impl<'a> From for ::std::borrow::Cow<'a, InstanceKey> { + #[inline] fn from(value: InstanceKey) -> Self { std::borrow::Cow::Owned(value) } } impl<'a> From<&'a InstanceKey> for ::std::borrow::Cow<'a, InstanceKey> { + #[inline] fn from(value: &'a InstanceKey) -> Self { std::borrow::Cow::Borrowed(value) } @@ -40,4 +42,66 @@ impl crate::Component for InstanceKey { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::UInt64, + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.components.InstanceKey".to_owned(), + Box::new(DataType::UInt64), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } diff --git a/crates/re_types/src/components/keypoint_id.rs b/crates/re_types/src/components/keypoint_id.rs index 7c8cee6bdebc..678890ccd866 100644 --- a/crates/re_types/src/components/keypoint_id.rs +++ b/crates/re_types/src/components/keypoint_id.rs @@ -17,12 +17,14 @@ pub struct KeypointId(pub u16); impl<'a> From for ::std::borrow::Cow<'a, KeypointId> { + #[inline] fn from(value: KeypointId) -> Self { std::borrow::Cow::Owned(value) } } impl<'a> From<&'a KeypointId> for ::std::borrow::Cow<'a, KeypointId> { + #[inline] fn from(value: &'a KeypointId) -> Self { std::borrow::Cow::Borrowed(value) } @@ -44,4 +46,66 @@ impl crate::Component for KeypointId { None, ) } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, data0): (Vec<_>, Vec<_>) = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + let datum = datum.map(|datum| { + let Self(data0) = datum.into_owned(); + data0 + }); + (datum.is_some(), datum) + }) + .unzip(); + let data0_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + DataType::UInt16, + data0.into_iter().map(|v| v.unwrap_or_default()).collect(), + data0_bitmap, + ) + .boxed() + }) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_from_arrow_opt( + data: &dyn ::arrow2::array::Array, + ) -> crate::DeserializationResult>> + where + Self: Sized, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok(data + .as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Extension( + "rerun.components.KeypointId".to_owned(), + Box::new(DataType::UInt16), + None, + ), + }) + }) + .map(|res| res.map(|v| Some(Self(v)))) + .collect::>>>()?) + } } diff --git a/crates/re_types/src/components/label.rs b/crates/re_types/src/components/label.rs index 4c6c762a8ba2..559afeeee02c 100644 --- a/crates/re_types/src/components/label.rs +++ b/crates/re_types/src/components/label.rs @@ -14,12 +14,14 @@ pub struct Label(pub String); impl<'a> From