diff --git a/crates/re_types/definitions/rerun/testing/archetypes/fuzzy.fbs b/crates/re_types/definitions/rerun/testing/archetypes/fuzzy.fbs index 50cb30970122..62b8d8b4d8a2 100644 --- a/crates/re_types/definitions/rerun/testing/archetypes/fuzzy.fbs +++ b/crates/re_types/definitions/rerun/testing/archetypes/fuzzy.fbs @@ -28,6 +28,12 @@ table AffixFuzzer1 ( fuzz1011: rerun.testing.components.AffixFuzzer11 ("attr.rerun.component_required", order: 1011); fuzz1012: rerun.testing.components.AffixFuzzer12 ("attr.rerun.component_required", order: 1012); fuzz1013: rerun.testing.components.AffixFuzzer13 ("attr.rerun.component_required", order: 1013); + fuzz1014: rerun.testing.components.AffixFuzzer14 ("attr.rerun.component_required", order: 1014); + // NOTE: nullable union -- illegal! + // fuzz1015: rerun.testing.components.AffixFuzzer15 ("attr.rerun.component_required", order: 1015); + fuzz1016: rerun.testing.components.AffixFuzzer16 ("attr.rerun.component_required", order: 1016); + fuzz1017: rerun.testing.components.AffixFuzzer17 ("attr.rerun.component_required", order: 1017); + fuzz1018: rerun.testing.components.AffixFuzzer18 ("attr.rerun.component_required", order: 1018); fuzz1101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_required", order: 1101); fuzz1102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_required", order: 1102); @@ -42,6 +48,12 @@ table AffixFuzzer1 ( fuzz1111: [rerun.testing.components.AffixFuzzer11] ("attr.rerun.component_required", order: 1111); fuzz1112: [rerun.testing.components.AffixFuzzer12] ("attr.rerun.component_required", order: 1112); fuzz1113: [rerun.testing.components.AffixFuzzer13] ("attr.rerun.component_required", order: 1113); + fuzz1114: [rerun.testing.components.AffixFuzzer14] ("attr.rerun.component_required", order: 1114); + // NOTE: nullable union -- illegal! + // fuzz1115: [rerun.testing.components.AffixFuzzer15] ("attr.rerun.component_required", order: 1115); + fuzz1116: [rerun.testing.components.AffixFuzzer16] ("attr.rerun.component_required", order: 1116); + fuzz1117: [rerun.testing.components.AffixFuzzer17] ("attr.rerun.component_required", order: 1117); + fuzz1118: [rerun.testing.components.AffixFuzzer18] ("attr.rerun.component_required", order: 1118); fuzz2001: rerun.testing.components.AffixFuzzer1 ("attr.rerun.component_optional", nullable, order: 2001); fuzz2002: rerun.testing.components.AffixFuzzer2 ("attr.rerun.component_optional", nullable, order: 2002); @@ -56,6 +68,12 @@ table AffixFuzzer1 ( fuzz2011: rerun.testing.components.AffixFuzzer11 ("attr.rerun.component_optional", nullable, order: 2011); fuzz2012: rerun.testing.components.AffixFuzzer12 ("attr.rerun.component_optional", nullable, order: 2012); fuzz2013: rerun.testing.components.AffixFuzzer13 ("attr.rerun.component_optional", nullable, order: 2013); + fuzz2014: rerun.testing.components.AffixFuzzer14 ("attr.rerun.component_optional", nullable, order: 2014); + // NOTE: nullable union -- illegal! + // fuzz2015: rerun.testing.components.AffixFuzzer15 ("attr.rerun.component_optional", nullable, order: 2015); + fuzz2016: rerun.testing.components.AffixFuzzer16 ("attr.rerun.component_optional", nullable, order: 2016); + fuzz2017: rerun.testing.components.AffixFuzzer17 ("attr.rerun.component_optional", nullable, order: 2017); + fuzz2018: rerun.testing.components.AffixFuzzer18 ("attr.rerun.component_optional", nullable, order: 2018); fuzz2101: [rerun.testing.components.AffixFuzzer1] ("attr.rerun.component_optional", nullable, order: 2101); fuzz2102: [rerun.testing.components.AffixFuzzer2] ("attr.rerun.component_optional", nullable, order: 2102); @@ -70,5 +88,10 @@ table AffixFuzzer1 ( fuzz2111: [rerun.testing.components.AffixFuzzer11] ("attr.rerun.component_optional", nullable, order: 2111); fuzz2112: [rerun.testing.components.AffixFuzzer12] ("attr.rerun.component_optional", nullable, order: 2112); fuzz2113: [rerun.testing.components.AffixFuzzer13] ("attr.rerun.component_optional", nullable, order: 2113); + fuzz2114: [rerun.testing.components.AffixFuzzer14] ("attr.rerun.component_optional", nullable, order: 2114); + // NOTE: nullable union -- illegal! + // fuzz2115: [rerun.testing.components.AffixFuzzer15] ("attr.rerun.component_optional", nullable, order: 2115); + fuzz2116: [rerun.testing.components.AffixFuzzer16] ("attr.rerun.component_optional", nullable, order: 2116); + fuzz2117: [rerun.testing.components.AffixFuzzer17] ("attr.rerun.component_optional", nullable, order: 2117); + fuzz2118: [rerun.testing.components.AffixFuzzer18] ("attr.rerun.component_optional", nullable, order: 2118); } - diff --git a/crates/re_types/definitions/rerun/testing/components/fuzzy.fbs b/crates/re_types/definitions/rerun/testing/components/fuzzy.fbs index 4ddf8697fde8..a35caaad493c 100644 --- a/crates/re_types/definitions/rerun/testing/components/fuzzy.fbs +++ b/crates/re_types/definitions/rerun/testing/components/fuzzy.fbs @@ -101,11 +101,47 @@ table AffixFuzzer13 ( many_strings_optional: [string] (nullable, order: 113); } +table AffixFuzzer14 ( + "attr.rust.derive": "PartialEq", + order: 1400 +) { + single_required_union: rerun.testing.datatypes.AffixFuzzer3 (order: 114); +} + +// NOTE: Illegal: union don't have top-level bitmaps! Commenting out will/should break the build. +// table AffixFuzzer15 ( +// "attr.rust.derive": "PartialEq", +// order: 1500 +// ) { +// single_optional_union: rerun.testing.datatypes.AffixFuzzer3 (nullable, order: 115); +// } + +table AffixFuzzer16 ( + "attr.rust.derive": "PartialEq", + order: 1600 +) { + many_required_unions: [rerun.testing.datatypes.AffixFuzzer3] (order: 116); +} + +table AffixFuzzer17 ( + "attr.rust.derive": "PartialEq", + order: 1700 +) { + many_optional_unions: [rerun.testing.datatypes.AffixFuzzer3] (nullable, order: 117); +} + +table AffixFuzzer18 ( + "attr.rust.derive": "PartialEq", + order: 1800 +) { + many_optional_unions: [rerun.testing.datatypes.AffixFuzzer4] (nullable, order: 118); +} + // TODO(cmc): the ugly bug we need to take care of at some point // table AffixFuzzer14 ( // "attr.rust.derive": "PartialEq", // order: 1400 // ) { // -// many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (order: 107); +// many_transparent_optionals: rerun.testing.datatypes.AffixFuzzer2 (nullable, order: 107); // } diff --git a/crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs b/crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs index 1948e0764493..7cabf5ce1568 100644 --- a/crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs +++ b/crates/re_types/definitions/rerun/testing/datatypes/fuzzy.fbs @@ -19,7 +19,7 @@ table VeryDeeplyFlattenedScalar (transparent, order: 001) { } table SurprisinglyShallowScalar (transparent, order: 001) { - value: FlattenedScalar (required, order: 100); + value: FlattenedScalar (order: 100); } table AffixFuzzer1 ( @@ -36,6 +36,10 @@ table AffixFuzzer1 ( almost_flattened_scalar: SurprisinglyShallowScalar (order: 108, transparent); } +table __AffixFuzzer1Vec (transparent, order: 0) { + inner: [AffixFuzzer1] (order: 0); +} + table AffixFuzzer2 ( "attr.arrow.transparent", "attr.rust.derive": "PartialEq", @@ -44,3 +48,29 @@ table AffixFuzzer2 ( ) { single_float_optional: float (nullable, order: 101); } + +union AffixFuzzer3 ( + "attr.rust.derive": "PartialEq", + order: 300 +) { + degrees: FlattenedScalar (transparent, order: 100), + radians: FlattenedScalar (transparent, nullable, order: 101), + craziness: __AffixFuzzer1Vec (transparent, order: 102), +} + +table __AffixFuzzer3 (transparent, order: 0) { + inner: AffixFuzzer3 (order: 0); +} + +table __AffixFuzzer3Vec (transparent, order: 0) { + inner: [AffixFuzzer3] (order: 0); +} + +union AffixFuzzer4 ( + "attr.rust.derive": "PartialEq", + order: 300 +) { + single_required: __AffixFuzzer3 (transparent, order: 100), + many_required: __AffixFuzzer3Vec (transparent, order: 101), + many_optional: __AffixFuzzer3Vec (transparent, order: 102, nullable), +} diff --git a/crates/re_types/source_hash.txt b/crates/re_types/source_hash.txt index 442b76b83ccf..2dbfc7674452 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. -b0b0d5d6d0f4131e52331303a2c2dfdfa11e03936e97242ef897c2b158979273 \ No newline at end of file +51e4e1d21a853de2f4d3b55d7d34d75cb3d6f0f7c01b701e9750256c759e9827 \ 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 22609bed9f1b..5fe8cdac0154 100644 --- a/crates/re_types/src/archetypes/fuzzy.rs +++ b/crates/re_types/src/archetypes/fuzzy.rs @@ -24,6 +24,10 @@ pub struct AffixFuzzer1 { pub fuzz1011: crate::components::AffixFuzzer11, pub fuzz1012: crate::components::AffixFuzzer12, pub fuzz1013: crate::components::AffixFuzzer13, + pub fuzz1014: crate::components::AffixFuzzer14, + pub fuzz1016: crate::components::AffixFuzzer16, + pub fuzz1017: crate::components::AffixFuzzer17, + pub fuzz1018: crate::components::AffixFuzzer18, pub fuzz1101: Vec, pub fuzz1102: Vec, pub fuzz1103: Vec, @@ -37,6 +41,10 @@ pub struct AffixFuzzer1 { pub fuzz1111: Vec, pub fuzz1112: Vec, pub fuzz1113: Vec, + pub fuzz1114: Vec, + pub fuzz1116: Vec, + pub fuzz1117: Vec, + pub fuzz1118: Vec, pub fuzz2001: Option, pub fuzz2002: Option, pub fuzz2003: Option, @@ -50,6 +58,10 @@ pub struct AffixFuzzer1 { pub fuzz2011: Option, pub fuzz2012: Option, pub fuzz2013: Option, + pub fuzz2014: Option, + pub fuzz2016: Option, + pub fuzz2017: Option, + pub fuzz2018: Option, pub fuzz2101: Option>, pub fuzz2102: Option>, pub fuzz2103: Option>, @@ -63,10 +75,14 @@ pub struct AffixFuzzer1 { pub fuzz2111: Option>, pub fuzz2112: Option>, pub fuzz2113: Option>, + pub fuzz2114: Option>, + pub fuzz2116: Option>, + pub fuzz2117: Option>, + pub fuzz2118: Option>, } impl AffixFuzzer1 { - pub const REQUIRED_COMPONENTS: [crate::ComponentName; 26usize] = [ + pub const REQUIRED_COMPONENTS: [crate::ComponentName; 34usize] = [ crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -80,6 +96,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -93,11 +113,15 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), ]; pub const RECOMMENDED_COMPONENTS: [crate::ComponentName; 0usize] = []; - pub const OPTIONAL_COMPONENTS: [crate::ComponentName; 26usize] = [ + pub const OPTIONAL_COMPONENTS: [crate::ComponentName; 34usize] = [ crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -111,6 +135,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -124,9 +152,13 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), ]; - pub const ALL_COMPONENTS: [crate::ComponentName; 52usize] = [ + pub const ALL_COMPONENTS: [crate::ComponentName; 68usize] = [ crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -140,6 +172,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -153,6 +189,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -166,6 +206,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer1"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer2"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer3"), @@ -179,6 +223,10 @@ impl AffixFuzzer1 { crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer11"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer12"), crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer13"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17"), + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18"), ]; } @@ -445,6 +493,78 @@ impl crate::Archetype for AffixFuzzer1 { }) .transpose()? }, + { + Some({ + let array = + ::try_to_arrow([&self.fuzz1014], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer14".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer14".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1014", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow([&self.fuzz1016], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer16".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer16".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1016", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow([&self.fuzz1017], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer17".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer17".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1017", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = + ::try_to_arrow([&self.fuzz1018], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer18".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer18".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1018", datatype, false), + array, + ) + }) + }) + .transpose()? + }, { Some({ let array = @@ -687,6 +807,86 @@ impl crate::Archetype for AffixFuzzer1 { }) .transpose()? }, + { + Some({ + let array = ::try_to_arrow( + self.fuzz1114.iter(), + None, + ); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer14".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer14".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1114", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow( + self.fuzz1116.iter(), + None, + ); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer16".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer16".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1116", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow( + self.fuzz1117.iter(), + None, + ); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer17".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer17".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1117", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + Some({ + let array = ::try_to_arrow( + self.fuzz1118.iter(), + None, + ); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer18".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer18".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz1118", datatype, false), + array, + ) + }) + }) + .transpose()? + }, { self.fuzz2001 .as_ref() @@ -938,6 +1138,86 @@ impl crate::Archetype for AffixFuzzer1 { }) .transpose()? }, + { + self.fuzz2014 + .as_ref() + .map(|single| { + let array = + ::try_to_arrow([single], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer14".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer14".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2014", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2016 + .as_ref() + .map(|single| { + let array = + ::try_to_arrow([single], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer16".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer16".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2016", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2017 + .as_ref() + .map(|single| { + let array = + ::try_to_arrow([single], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer17".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer17".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2017", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2018 + .as_ref() + .map(|single| { + let array = + ::try_to_arrow([single], None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer18".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer18".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2018", datatype, false), + array, + ) + }) + }) + .transpose()? + }, { self.fuzz2101 .as_ref() @@ -1198,6 +1478,86 @@ impl crate::Archetype for AffixFuzzer1 { }) .transpose()? }, + { + self.fuzz2114 + .as_ref() + .map(|many| { + let array = + ::try_to_arrow(many.iter(), None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer14".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer14".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2114", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2116 + .as_ref() + .map(|many| { + let array = + ::try_to_arrow(many.iter(), None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer16".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer16".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2116", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2117 + .as_ref() + .map(|many| { + let array = + ::try_to_arrow(many.iter(), None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer17".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer17".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2117", datatype, false), + array, + ) + }) + }) + .transpose()? + }, + { + self.fuzz2118 + .as_ref() + .map(|many| { + let array = + ::try_to_arrow(many.iter(), None); + array.map(|array| { + let datatype = ::arrow2::datatypes::DataType::Extension( + "rerun.testing.components.AffixFuzzer18".into(), + Box::new(array.data_type().clone()), + Some("rerun.testing.components.AffixFuzzer18".into()), + ); + ( + ::arrow2::datatypes::Field::new("fuzz2118", datatype, false), + array, + ) + }) + }) + .transpose()? + }, ] .into_iter() .flatten() @@ -1395,6 +1755,62 @@ impl crate::Archetype for AffixFuzzer1 { datatype: ::arrow2::datatypes::DataType::Null, })? }; + let fuzz1014 = { + let array = arrays_by_name.get("fuzz1014").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 fuzz1016 = { + let array = arrays_by_name.get("fuzz1016").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 fuzz1017 = { + let array = arrays_by_name.get("fuzz1017").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 fuzz1018 = { + let array = arrays_by_name.get("fuzz1018").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 { @@ -1590,6 +2006,66 @@ impl crate::Archetype for AffixFuzzer1 { }) .collect::>>()? }; + let fuzz1114 = { + let array = arrays_by_name.get("fuzz1114").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 fuzz1116 = { + let array = arrays_by_name.get("fuzz1116").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 fuzz1117 = { + let array = arrays_by_name.get("fuzz1117").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 fuzz1118 = { + let array = arrays_by_name.get("fuzz1118").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)? @@ -1759,6 +2235,58 @@ impl crate::Archetype for AffixFuzzer1 { } else { None }; + let fuzz2014 = if let Some(array) = arrays_by_name.get("fuzz2014") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2016 = if let Some(array) = arrays_by_name.get("fuzz2016") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2017 = if let Some(array) = arrays_by_name.get("fuzz2017") { + Some( + ::try_from_arrow_opt(&**array)? + .into_iter() + .next() + .flatten() + .ok_or_else(|| crate::DeserializationError::MissingData { + datatype: ::arrow2::datatypes::DataType::Null, + })?, + ) + } else { + None + }; + let fuzz2018 = if let Some(array) = arrays_by_name.get("fuzz2018") { + 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)? @@ -1941,6 +2469,62 @@ impl crate::Archetype for AffixFuzzer1 { } else { None }; + let fuzz2114 = if let Some(array) = arrays_by_name.get("fuzz2114") { + 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 fuzz2116 = if let Some(array) = arrays_by_name.get("fuzz2116") { + 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 fuzz2117 = if let Some(array) = arrays_by_name.get("fuzz2117") { + 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 fuzz2118 = if let Some(array) = arrays_by_name.get("fuzz2118") { + 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, @@ -1955,6 +2539,10 @@ impl crate::Archetype for AffixFuzzer1 { fuzz1011, fuzz1012, fuzz1013, + fuzz1014, + fuzz1016, + fuzz1017, + fuzz1018, fuzz1101, fuzz1102, fuzz1103, @@ -1968,6 +2556,10 @@ impl crate::Archetype for AffixFuzzer1 { fuzz1111, fuzz1112, fuzz1113, + fuzz1114, + fuzz1116, + fuzz1117, + fuzz1118, fuzz2001, fuzz2002, fuzz2003, @@ -1981,6 +2573,10 @@ impl crate::Archetype for AffixFuzzer1 { fuzz2011, fuzz2012, fuzz2013, + fuzz2014, + fuzz2016, + fuzz2017, + fuzz2018, fuzz2101, fuzz2102, fuzz2103, @@ -1994,6 +2590,10 @@ impl crate::Archetype for AffixFuzzer1 { fuzz2111, fuzz2112, fuzz2113, + fuzz2114, + fuzz2116, + fuzz2117, + fuzz2118, }) } } @@ -2013,6 +2613,10 @@ impl AffixFuzzer1 { fuzz1011: impl Into, fuzz1012: impl Into, fuzz1013: impl Into, + fuzz1014: impl Into, + fuzz1016: impl Into, + fuzz1017: impl Into, + fuzz1018: impl Into, fuzz1101: impl IntoIterator>, fuzz1102: impl IntoIterator>, fuzz1103: impl IntoIterator>, @@ -2026,6 +2630,10 @@ impl AffixFuzzer1 { fuzz1111: impl IntoIterator>, fuzz1112: impl IntoIterator>, fuzz1113: impl IntoIterator>, + fuzz1114: impl IntoIterator>, + fuzz1116: impl IntoIterator>, + fuzz1117: impl IntoIterator>, + fuzz1118: impl IntoIterator>, ) -> Self { Self { fuzz1001: fuzz1001.into(), @@ -2041,6 +2649,10 @@ impl AffixFuzzer1 { fuzz1011: fuzz1011.into(), fuzz1012: fuzz1012.into(), fuzz1013: fuzz1013.into(), + fuzz1014: fuzz1014.into(), + fuzz1016: fuzz1016.into(), + fuzz1017: fuzz1017.into(), + fuzz1018: fuzz1018.into(), fuzz1101: fuzz1101.into_iter().map(Into::into).collect(), fuzz1102: fuzz1102.into_iter().map(Into::into).collect(), fuzz1103: fuzz1103.into_iter().map(Into::into).collect(), @@ -2054,6 +2666,10 @@ impl AffixFuzzer1 { fuzz1111: fuzz1111.into_iter().map(Into::into).collect(), fuzz1112: fuzz1112.into_iter().map(Into::into).collect(), fuzz1113: fuzz1113.into_iter().map(Into::into).collect(), + fuzz1114: fuzz1114.into_iter().map(Into::into).collect(), + fuzz1116: fuzz1116.into_iter().map(Into::into).collect(), + fuzz1117: fuzz1117.into_iter().map(Into::into).collect(), + fuzz1118: fuzz1118.into_iter().map(Into::into).collect(), fuzz2001: None, fuzz2002: None, fuzz2003: None, @@ -2067,6 +2683,10 @@ impl AffixFuzzer1 { fuzz2011: None, fuzz2012: None, fuzz2013: None, + fuzz2014: None, + fuzz2016: None, + fuzz2017: None, + fuzz2018: None, fuzz2101: None, fuzz2102: None, fuzz2103: None, @@ -2080,6 +2700,10 @@ impl AffixFuzzer1 { fuzz2111: None, fuzz2112: None, fuzz2113: None, + fuzz2114: None, + fuzz2116: None, + fuzz2117: None, + fuzz2118: None, } } @@ -2148,6 +2772,26 @@ impl AffixFuzzer1 { self } + pub fn with_fuzz2014(mut self, fuzz2014: impl Into) -> Self { + self.fuzz2014 = Some(fuzz2014.into()); + self + } + + pub fn with_fuzz2016(mut self, fuzz2016: impl Into) -> Self { + self.fuzz2016 = Some(fuzz2016.into()); + self + } + + pub fn with_fuzz2017(mut self, fuzz2017: impl Into) -> Self { + self.fuzz2017 = Some(fuzz2017.into()); + self + } + + pub fn with_fuzz2018(mut self, fuzz2018: impl Into) -> Self { + self.fuzz2018 = Some(fuzz2018.into()); + self + } + pub fn with_fuzz2101( mut self, fuzz2101: impl IntoIterator>, @@ -2251,4 +2895,36 @@ impl AffixFuzzer1 { self.fuzz2113 = Some(fuzz2113.into_iter().map(Into::into).collect()); self } + + pub fn with_fuzz2114( + mut self, + fuzz2114: impl IntoIterator>, + ) -> Self { + self.fuzz2114 = Some(fuzz2114.into_iter().map(Into::into).collect()); + self + } + + pub fn with_fuzz2116( + mut self, + fuzz2116: impl IntoIterator>, + ) -> Self { + self.fuzz2116 = Some(fuzz2116.into_iter().map(Into::into).collect()); + self + } + + pub fn with_fuzz2117( + mut self, + fuzz2117: impl IntoIterator>, + ) -> Self { + self.fuzz2117 = Some(fuzz2117.into_iter().map(Into::into).collect()); + self + } + + pub fn with_fuzz2118( + mut self, + fuzz2118: impl IntoIterator>, + ) -> Self { + self.fuzz2118 = Some(fuzz2118.into_iter().map(Into::into).collect()); + self + } } diff --git a/crates/re_types/src/components/fuzzy.rs b/crates/re_types/src/components/fuzzy.rs index 92d070bd0bd5..86dce356d09d 100644 --- a/crates/re_types/src/components/fuzzy.rs +++ b/crates/re_types/src/components/fuzzy.rs @@ -2333,3 +2333,2133 @@ impl crate::Component for AffixFuzzer13 { .collect::>>>()?) } } + +#[derive(Debug, Clone, PartialEq)] +pub struct AffixFuzzer14 { + pub single_required_union: crate::datatypes::AffixFuzzer3, +} + +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer14> { + #[inline] + fn from(value: AffixFuzzer14) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer14> for ::std::borrow::Cow<'a, AffixFuzzer14> { + #[inline] + fn from(value: &'a AffixFuzzer14) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + +impl crate::Component for AffixFuzzer14 { + #[inline] + fn name() -> crate::ComponentName { + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer14") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, single_required_union): (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_union, + } = datum.into_owned(); + single_required_union + }); + (datum.is_some(), datum) + }) + .unzip(); + let single_required_union_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + { + _ = single_required_union_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + single_required_union, + Some("rerun.testing.components.AffixFuzzer14"), + )? + } + }) + } + + #[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::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: data.data_type().clone(), + }) + }) + .map(|res| { + res.map(|single_required_union| { + Some(Self { + single_required_union, + }) + }) + }) + .collect::>>>()?) + } +} + +#[derive(Debug, Clone, PartialEq)] +pub struct AffixFuzzer16 { + pub many_required_unions: Vec, +} + +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer16> { + #[inline] + fn from(value: AffixFuzzer16) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer16> for ::std::borrow::Cow<'a, AffixFuzzer16> { + #[inline] + fn from(value: &'a AffixFuzzer16) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + +impl crate::Component for AffixFuzzer16 { + #[inline] + fn name() -> crate::ComponentName { + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer16") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + })) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, many_required_unions): (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 { + many_required_unions, + } = datum.into_owned(); + many_required_unions + }); + (datum.is_some(), datum) + }) + .unzip(); + let many_required_unions_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_required_unions_inner_data: Vec<_> = many_required_unions + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_required_unions_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = many_required_unions_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_required_unions_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_required_unions + .iter() + .map(|opt| opt.as_ref().map(|datum| datum.len()).unwrap_or_default()), + ) + .unwrap() + .into(); + ListArray::new( + { + _ = extension_wrapper; + DataType::Extension( + "rerun.testing.components.AffixFuzzer16".to_owned(), + Box::new(DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + }))), + None, + ) + .to_logical_type() + .clone() + }, + offsets, + { + _ = many_required_unions_inner_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + many_required_unions_inner_data, + Some("rerun.testing.components.AffixFuzzer16"), + )? + }, + many_required_unions_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 datatype = data.data_type(); + 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::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + }) + }) + .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.clone(), + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: data.data_type().clone(), + }) + }) + .map(|res| { + res.map(|many_required_unions| { + Some(Self { + many_required_unions, + }) + }) + }) + .collect::>>>()?) + } +} + +#[derive(Debug, Clone, PartialEq)] +pub struct AffixFuzzer17 { + pub many_optional_unions: Option>, +} + +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer17> { + #[inline] + fn from(value: AffixFuzzer17) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer17> for ::std::borrow::Cow<'a, AffixFuzzer17> { + #[inline] + fn from(value: &'a AffixFuzzer17) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + +impl crate::Component for AffixFuzzer17 { + #[inline] + fn name() -> crate::ComponentName { + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer17") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, many_optional_unions): (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 { + many_optional_unions, + } = datum.into_owned(); + many_optional_unions + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let many_optional_unions_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_unions_inner_data: Vec<_> = many_optional_unions + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_optional_unions_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = many_optional_unions_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_optional_unions_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_optional_unions + .iter() + .map(|opt| opt.as_ref().map(|datum| datum.len()).unwrap_or_default()), + ) + .unwrap() + .into(); + ListArray::new( + { + _ = extension_wrapper; + DataType::Extension( + "rerun.testing.components.AffixFuzzer17".to_owned(), + Box::new(DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + }))), + None, + ) + .to_logical_type() + .clone() + }, + offsets, + { + _ = many_optional_unions_inner_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + many_optional_unions_inner_data, + Some("rerun.testing.components.AffixFuzzer17"), + )? + }, + many_optional_unions_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 datatype = data.data_type(); + 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::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + }) + }) + .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.clone(), + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .map(Ok) + .map(|res| { + res.map(|many_optional_unions| { + Some(Self { + many_optional_unions, + }) + }) + }) + .collect::>>>()?) + } +} + +#[derive(Debug, Clone, PartialEq)] +pub struct AffixFuzzer18 { + pub many_optional_unions: Option>, +} + +impl<'a> From for ::std::borrow::Cow<'a, AffixFuzzer18> { + #[inline] + fn from(value: AffixFuzzer18) -> Self { + std::borrow::Cow::Owned(value) + } +} + +impl<'a> From<&'a AffixFuzzer18> for ::std::borrow::Cow<'a, AffixFuzzer18> { + #[inline] + fn from(value: &'a AffixFuzzer18) -> Self { + std::borrow::Cow::Borrowed(value) + } +} + +impl crate::Component for AffixFuzzer18 { + #[inline] + fn name() -> crate::ComponentName { + crate::ComponentName::Borrowed("rerun.testing.components.AffixFuzzer18") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "single_required".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let (somes, many_optional_unions): (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 { + many_optional_unions, + } = datum.into_owned(); + many_optional_unions + }) + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let many_optional_unions_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_unions_inner_data: Vec<_> = many_optional_unions + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_optional_unions_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = many_optional_unions_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_optional_unions_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_optional_unions + .iter() + .map(|opt| opt.as_ref().map(|datum| datum.len()).unwrap_or_default()), + ) + .unwrap() + .into(); + ListArray :: new ({ _ = extension_wrapper ; DataType :: Extension ("rerun.testing.components.AffixFuzzer18" . to_owned () , Box :: new (DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : DataType :: Union (vec ! [Field { name : "single_required" . to_owned () , data_type : DataType :: Union (vec ! [Field { name : "degrees" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "radians" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "craziness" . to_owned () , data_type : DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : 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 () , } + + , Field { name : "flattened_scalar" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "almost_flattened_scalar" . to_owned () , data_type : DataType :: Struct (vec ! [Field { name : "value" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + +)) , is_nullable : false , metadata : [] . into () , } + + ,] , None , UnionMode :: Dense) , is_nullable : false , metadata : [] . into () , } + + , Field { name : "many_required" . to_owned () , data_type : DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : DataType :: Union (vec ! [Field { name : "degrees" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "radians" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "craziness" . to_owned () , data_type : DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : 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 () , } + + , Field { name : "flattened_scalar" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "almost_flattened_scalar" . to_owned () , data_type : DataType :: Struct (vec ! [Field { name : "value" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + +)) , is_nullable : false , metadata : [] . into () , } + + ,] , None , UnionMode :: Dense) , is_nullable : false , metadata : [] . into () , } + +)) , is_nullable : false , metadata : [] . into () , } + + , Field { name : "many_optional" . to_owned () , data_type : DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : DataType :: Union (vec ! [Field { name : "degrees" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "radians" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "craziness" . to_owned () , data_type : DataType :: List (Box :: new (Field { name : "item" . to_owned () , data_type : 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 () , } + + , Field { name : "flattened_scalar" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + , Field { name : "almost_flattened_scalar" . to_owned () , data_type : DataType :: Struct (vec ! [Field { name : "value" . to_owned () , data_type : DataType :: Float32 , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + + ,]) , is_nullable : false , metadata : [] . into () , } + +)) , is_nullable : false , metadata : [] . into () , } + + ,] , None , UnionMode :: Dense) , is_nullable : true , metadata : [] . into () , } + +)) , is_nullable : false , metadata : [] . into () , } + + ,] , None , UnionMode :: Dense) , is_nullable : true , metadata : [] . into () , } + +))) , None) . to_logical_type () . clone () } + + , offsets , { _ = many_optional_unions_inner_bitmap ; _ = extension_wrapper ; crate :: datatypes :: AffixFuzzer4 :: try_to_arrow_opt (many_optional_unions_inner_data , Some ("rerun.testing.components.AffixFuzzer18")) ? } + + , many_optional_unions_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 datatype = data.data_type(); + 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::AffixFuzzer4::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Union( + vec![ + Field { + name: "single_required".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar" + .to_owned(), + data_type: DataType::Struct(vec![ + Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar" + .to_owned(), + data_type: DataType::Struct(vec![ + Field { + name: "value".to_owned(), + data_type: + DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar" + .to_owned(), + data_type: DataType::Struct(vec![ + Field { + name: "value".to_owned(), + data_type: + DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + }) + }) + .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.clone(), + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .map(Ok) + .map(|res| { + res.map(|many_optional_unions| { + Some(Self { + many_optional_unions, + }) + }) + }) + .collect::>>>()?) + } +} diff --git a/crates/re_types/src/components/mod.rs b/crates/re_types/src/components/mod.rs index c78f73fde1c8..2270c64ddc68 100644 --- a/crates/re_types/src/components/mod.rs +++ b/crates/re_types/src/components/mod.rs @@ -22,9 +22,9 @@ pub use self::class_id::ClassId; pub use self::color::Color; pub use self::draw_order::DrawOrder; pub use self::fuzzy::{ - AffixFuzzer1, AffixFuzzer10, AffixFuzzer11, AffixFuzzer12, AffixFuzzer13, AffixFuzzer2, - AffixFuzzer3, AffixFuzzer4, AffixFuzzer5, AffixFuzzer6, AffixFuzzer7, AffixFuzzer8, - AffixFuzzer9, + AffixFuzzer1, AffixFuzzer10, AffixFuzzer11, AffixFuzzer12, AffixFuzzer13, AffixFuzzer14, + AffixFuzzer16, AffixFuzzer17, AffixFuzzer18, AffixFuzzer2, AffixFuzzer3, AffixFuzzer4, + AffixFuzzer5, AffixFuzzer6, AffixFuzzer7, AffixFuzzer8, AffixFuzzer9, }; pub use self::instance_key::InstanceKey; pub use self::keypoint_id::KeypointId; diff --git a/crates/re_types/src/datatypes/fuzzy.rs b/crates/re_types/src/datatypes/fuzzy.rs index 8498243f1c7d..dfbbe5b6c8de 100644 --- a/crates/re_types/src/datatypes/fuzzy.rs +++ b/crates/re_types/src/datatypes/fuzzy.rs @@ -1150,3 +1150,1800 @@ impl crate::Datatype for AffixFuzzer2 { .collect::>>>()?) } } + +#[derive(Debug, Clone, PartialEq)] +pub enum AffixFuzzer3 { + Degrees(f32), + Radians(Option), + Craziness(Vec), +} + +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::Datatype for AffixFuzzer3 { + #[inline] + fn name() -> crate::DatatypeName { + crate::DatatypeName::Borrowed("rerun.testing.datatypes.AffixFuzzer3") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let data: Vec<_> = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + datum + }) + .collect(); + UnionArray::new( + (if let Some(ext) = extension_wrapper { + DataType::Extension( + ext.to_owned(), + Box::new(::to_arrow_datatype()), + None, + ) + } else { + ::to_arrow_datatype() + }) + .to_logical_type() + .clone(), + { + data.iter() + .flatten() + .map(|v| match **v { + AffixFuzzer3::Degrees(_) => 0i8, + AffixFuzzer3::Radians(_) => 1i8, + AffixFuzzer3::Craziness(_) => 2i8, + }) + .collect() + }, + vec![ + { + let (somes, degrees): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer3::Degrees(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer3::Degrees(v) => Some(v.clone()), + _ => None, + }; + (datum.is_some(), datum) + }) + .unzip(); + let degrees_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + { + _ = extension_wrapper; + DataType::Float32.to_logical_type().clone() + }, + degrees.into_iter().map(|v| v.unwrap_or_default()).collect(), + degrees_bitmap, + ) + .boxed() + }, + { + let (somes, radians): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer3::Radians(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer3::Radians(v) => Some(v.clone()), + _ => None, + } + .flatten(); + (datum.is_some(), datum) + }) + .unzip(); + let radians_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = somes.iter().any(|some| !*some); + any_nones.then(|| somes.into()) + }; + PrimitiveArray::new( + { + _ = extension_wrapper; + DataType::Float32.to_logical_type().clone() + }, + radians.into_iter().map(|v| v.unwrap_or_default()).collect(), + radians_bitmap, + ) + .boxed() + }, + { + let (somes, craziness): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer3::Craziness(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer3::Craziness(v) => Some(v.clone()), + _ => None, + }; + (datum.is_some(), datum) + }) + .unzip(); + let craziness_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 craziness_inner_data: Vec<_> = craziness + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let craziness_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = craziness_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + craziness_inner_data.iter().map(|v| v.is_some()).collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + craziness.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + { + _ = extension_wrapper; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })) + .to_logical_type() + .clone() + }, + offsets, + { + _ = craziness_inner_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer1::try_to_arrow_opt( + craziness_inner_data, + None::<&str>, + )? + }, + craziness_bitmap, + ) + .boxed() + } + }, + ], + Some({ + let mut degrees_offset = 0; + let mut radians_offset = 0; + let mut craziness_offset = 0; + data.iter() + .flatten() + .map(|v| match **v { + AffixFuzzer3::Degrees(_) => { + let offset = degrees_offset; + degrees_offset += 1; + offset + } + + AffixFuzzer3::Radians(_) => { + let offset = radians_offset; + radians_offset += 1; + offset + } + + AffixFuzzer3::Craziness(_) => { + let offset = craziness_offset; + craziness_offset += 1; + offset + } + }) + .collect() + }), + ) + .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::UnionArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: data.data_type().clone(), + got: data.data_type().clone(), + })?; + let (data_types, data_arrays, data_offsets) = + (data.types(), data.fields(), data.offsets().unwrap()); + let degrees = { + let data = &*data_arrays[0usize]; + + data.as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .collect::>() + }; + let radians = { + let data = &*data_arrays[1usize]; + + data.as_any() + .downcast_ref::() + .unwrap() + .into_iter() + .map(|v| v.copied()) + .collect::>() + }; + let craziness = { + let data = &*data_arrays[2usize]; + + { + let datatype = data.data_type(); + 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::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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + }) + }) + .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.clone(), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .collect::>() + }; + data_types + .iter() + .enumerate() + .map(|(i, typ)| { + let offset = data_offsets[i]; + + Ok(Some(match typ { + 0i8 => AffixFuzzer3::Degrees( + degrees + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: degrees.len(), + datatype: data.data_type().clone(), + })? + .clone() + .unwrap(), + ), + 1i8 => AffixFuzzer3::Radians( + radians + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: radians.len(), + datatype: data.data_type().clone(), + })? + .clone(), + ), + 2i8 => AffixFuzzer3::Craziness( + craziness + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: craziness.len(), + datatype: data.data_type().clone(), + })? + .clone() + .unwrap(), + ), + _ => unreachable!(), + })) + }) + .collect::>>()? + }) + } +} + +#[derive(Debug, Clone, PartialEq)] +pub enum AffixFuzzer4 { + SingleRequired(crate::datatypes::AffixFuzzer3), + ManyRequired(Vec), + ManyOptional(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::Datatype for AffixFuzzer4 { + #[inline] + fn name() -> crate::DatatypeName { + crate::DatatypeName::Borrowed("rerun.testing.datatypes.AffixFuzzer4") + } + + #[allow(unused_imports, clippy::wildcard_imports)] + #[inline] + fn to_arrow_datatype() -> arrow2::datatypes::DataType { + use ::arrow2::datatypes::*; + DataType::Union( + vec![ + Field { + name: "single_required".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_required".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "many_optional".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ) + } + + #[allow(unused_imports, clippy::wildcard_imports)] + fn try_to_arrow_opt<'a>( + data: impl IntoIterator>>>, + extension_wrapper: Option<&str>, + ) -> crate::SerializationResult> + where + Self: Clone + 'a, + { + use crate::{Component as _, Datatype as _}; + use ::arrow2::{array::*, datatypes::*}; + Ok({ + let data: Vec<_> = data + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + datum + }) + .collect(); + UnionArray::new( + (if let Some(ext) = extension_wrapper { + DataType::Extension( + ext.to_owned(), + Box::new(::to_arrow_datatype()), + None, + ) + } else { + ::to_arrow_datatype() + }) + .to_logical_type() + .clone(), + { + data.iter() + .flatten() + .map(|v| match **v { + AffixFuzzer4::SingleRequired(_) => 0i8, + AffixFuzzer4::ManyRequired(_) => 1i8, + AffixFuzzer4::ManyOptional(_) => 2i8, + }) + .collect() + }, + vec![ + { + let (somes, single_required): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer4::SingleRequired(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer4::SingleRequired(v) => Some(v.clone()), + _ => None, + }; + (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; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + single_required, + None::<&str>, + )? + } + }, + { + let (somes, many_required): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer4::ManyRequired(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer4::ManyRequired(v) => Some(v.clone()), + _ => None, + }; + (datum.is_some(), datum) + }) + .unzip(); + let many_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_required_inner_data: Vec<_> = many_required + .iter() + .flatten() + .flatten() + .map(ToOwned::to_owned) + .map(Some) + .collect(); + let many_required_inner_bitmap: Option<::arrow2::bitmap::Bitmap> = { + let any_nones = + many_required_inner_data.iter().any(|v| v.is_none()); + any_nones.then(|| { + many_required_inner_data + .iter() + .map(|v| v.is_some()) + .collect() + }) + }; + let offsets = ::arrow2::offset::Offsets::::try_from_lengths( + many_required.iter().map(|opt| { + opt.as_ref().map(|datum| datum.len()).unwrap_or_default() + }), + ) + .unwrap() + .into(); + ListArray::new( + { + _ = extension_wrapper; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar" + .to_owned(), + data_type: DataType::Struct(vec![ + Field { + name: "value".to_owned(), + data_type: + DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: false, + metadata: [].into(), + })) + .to_logical_type() + .clone() + }, + offsets, + { + _ = many_required_inner_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + many_required_inner_data, + None::<&str>, + )? + }, + many_required_bitmap, + ) + .boxed() + } + }, + { + let (somes, many_optional): (Vec<_>, Vec<_>) = data + .iter() + .flatten() + .filter(|datum| matches!(***datum, AffixFuzzer4::ManyOptional(_))) + .map(|datum| { + let datum = match &**datum { + AffixFuzzer4::ManyOptional(v) => Some(v.clone()), + _ => None, + } + .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( + { + _ = extension_wrapper; + DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar" + .to_owned(), + data_type: DataType::Struct(vec![ + Field { + name: "value".to_owned(), + data_type: + DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + is_nullable: true, + metadata: [].into(), + })) + .to_logical_type() + .clone() + }, + offsets, + { + _ = many_optional_inner_bitmap; + _ = extension_wrapper; + crate::datatypes::AffixFuzzer3::try_to_arrow_opt( + many_optional_inner_data, + None::<&str>, + )? + }, + many_optional_bitmap, + ) + .boxed() + } + }, + ], + Some({ + let mut single_required_offset = 0; + let mut many_required_offset = 0; + let mut many_optional_offset = 0; + data.iter() + .flatten() + .map(|v| match **v { + AffixFuzzer4::SingleRequired(_) => { + let offset = single_required_offset; + single_required_offset += 1; + offset + } + + AffixFuzzer4::ManyRequired(_) => { + let offset = many_required_offset; + many_required_offset += 1; + offset + } + + AffixFuzzer4::ManyOptional(_) => { + let offset = many_optional_offset; + many_optional_offset += 1; + offset + } + }) + .collect() + }), + ) + .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::UnionArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: data.data_type().clone(), + got: data.data_type().clone(), + })?; + let (data_types, data_arrays, data_offsets) = + (data.types(), data.fields(), data.offsets().unwrap()); + let single_required = { + let data = &*data_arrays[0usize]; + + crate::datatypes::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .collect::>() + }; + let many_required = { + let data = &*data_arrays[1usize]; + + { + let datatype = data.data_type(); + 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::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + }) + }) + .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.clone(), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .collect::>() + }; + let many_optional = { + let data = &*data_arrays[2usize]; + + { + let datatype = data.data_type(); + 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::AffixFuzzer3::try_from_arrow_opt(data)? + .into_iter() + .map(|v| { + v.ok_or_else(|| crate::DeserializationError::MissingData { + datatype: DataType::Union( + vec![ + Field { + name: "degrees".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "radians".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "craziness".to_owned(), + data_type: DataType::List(Box::new(Field { + name: "item".to_owned(), + data_type: 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(), + }, + Field { + name: "flattened_scalar".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }, + Field { + name: "almost_flattened_scalar".to_owned(), + data_type: DataType::Struct(vec![Field { + name: "value".to_owned(), + data_type: DataType::Float32, + is_nullable: false, + metadata: [].into(), + }]), + is_nullable: false, + metadata: [].into(), + }, + ]), + is_nullable: false, + metadata: [].into(), + })), + is_nullable: false, + metadata: [].into(), + }, + ], + None, + UnionMode::Dense, + ), + }) + }) + .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.clone(), + } + })? + .to_vec()) + }) + .transpose() + }) + .collect::>>>()? + .into_iter() + } + .collect::>() + }; + data_types + .iter() + .enumerate() + .map(|(i, typ)| { + let offset = data_offsets[i]; + + Ok(Some(match typ { + 0i8 => AffixFuzzer4::SingleRequired( + single_required + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: single_required.len(), + datatype: data.data_type().clone(), + })? + .clone() + .unwrap(), + ), + 1i8 => AffixFuzzer4::ManyRequired( + many_required + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: many_required.len(), + datatype: data.data_type().clone(), + })? + .clone() + .unwrap(), + ), + 2i8 => AffixFuzzer4::ManyOptional( + many_optional + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: many_optional.len(), + datatype: data.data_type().clone(), + })? + .clone(), + ), + _ => unreachable!(), + })) + }) + .collect::>>()? + }) + } +} diff --git a/crates/re_types/src/datatypes/mod.rs b/crates/re_types/src/datatypes/mod.rs index 57ee71907bf6..6cd583697d69 100644 --- a/crates/re_types/src/datatypes/mod.rs +++ b/crates/re_types/src/datatypes/mod.rs @@ -6,6 +6,6 @@ mod point2d_ext; mod vec2d; mod vec2d_ext; -pub use self::fuzzy::{AffixFuzzer1, AffixFuzzer2, FlattenedScalar}; +pub use self::fuzzy::{AffixFuzzer1, AffixFuzzer2, AffixFuzzer3, AffixFuzzer4, FlattenedScalar}; pub use self::point2d::Point2D; pub use self::vec2d::Vec2D; diff --git a/crates/re_types/tests/fuzzy.rs b/crates/re_types/tests/fuzzy.rs index 3e471b2dbd7c..7eec20965400 100644 --- a/crates/re_types/tests/fuzzy.rs +++ b/crates/re_types/tests/fuzzy.rs @@ -1,6 +1,6 @@ #![allow(clippy::redundant_clone)] -use std::collections::HashMap; +use std::{collections::HashMap, f32::consts::PI}; use re_types::{archetypes::AffixFuzzer1, Archetype as _}; @@ -143,6 +143,107 @@ fn roundtrip() { ]), }; + let fuzzy14_1 = re_types::components::AffixFuzzer14 { + single_required_union: re_types::datatypes::AffixFuzzer3::Degrees(90.0), + }; + let fuzzy14_2 = re_types::components::AffixFuzzer14 { + single_required_union: re_types::datatypes::AffixFuzzer3::Radians(Some(PI)), + }; + let fuzzy14_3 = re_types::components::AffixFuzzer14 { + single_required_union: re_types::datatypes::AffixFuzzer3::Radians(None), + }; + + // NOTE: nullable union -- illegal! + // let fuzzy15_1 = re_types::components::AffixFuzzer15 { + // single_optional_union: None, + // }; + // let fuzzy15_2 = re_types::components::AffixFuzzer15 { + // single_optional_union: Some(re_types::datatypes::AffixFuzzer3::Radians(PI / 4.0)), + // }; + + let fuzzy16_1 = re_types::components::AffixFuzzer16 { + many_required_unions: vec![ + re_types::datatypes::AffixFuzzer3::Radians(None), // + re_types::datatypes::AffixFuzzer3::Degrees(45.0), // + re_types::datatypes::AffixFuzzer3::Radians(Some(PI * 2.0)), // + ], + }; + let fuzzy16_2 = re_types::components::AffixFuzzer16 { + many_required_unions: vec![ + re_types::datatypes::AffixFuzzer3::Degrees(20.0), // + re_types::datatypes::AffixFuzzer3::Degrees(30.0), // + re_types::datatypes::AffixFuzzer3::Radians(Some(0.424242)), // + ], + }; + + let fuzzy17_1 = re_types::components::AffixFuzzer17 { + many_optional_unions: None, + }; + let fuzzy17_2 = re_types::components::AffixFuzzer17 { + many_optional_unions: Some(vec![ + re_types::datatypes::AffixFuzzer3::Degrees(20.0), // + re_types::datatypes::AffixFuzzer3::Degrees(30.0), // + re_types::datatypes::AffixFuzzer3::Radians(None), // + ]), + }; + + let fuzzy18_1 = re_types::components::AffixFuzzer18 { + many_optional_unions: None, + }; + let fuzzy18_2 = re_types::components::AffixFuzzer18 { + many_optional_unions: Some(vec![ + re_types::datatypes::AffixFuzzer4::SingleRequired( + re_types::datatypes::AffixFuzzer3::Craziness(vec![ + re_types::datatypes::AffixFuzzer1 { + single_float_optional: None, + single_string_required: "d".into(), + single_string_optional: None, + many_floats_optional: Some(vec![4.0, 40.0, 400.0]), + many_strings_required: vec!["7".into(), "8".into()], + many_strings_optional: None, + flattened_scalar: 46.0, + almost_flattened_scalar: re_types::datatypes::FlattenedScalar { + value: 46.0, + }, + }, + ]), + ), // + re_types::datatypes::AffixFuzzer4::SingleRequired( + re_types::datatypes::AffixFuzzer3::Degrees(30.0), + ), // + re_types::datatypes::AffixFuzzer4::SingleRequired( + re_types::datatypes::AffixFuzzer3::Radians(None), + ), // + ]), + }; + let fuzzy18_3 = re_types::components::AffixFuzzer18 { + many_optional_unions: Some(vec![ + re_types::datatypes::AffixFuzzer4::ManyRequired(vec![ + re_types::datatypes::AffixFuzzer3::Radians(None), // + re_types::datatypes::AffixFuzzer3::Degrees(45.0), // + re_types::datatypes::AffixFuzzer3::Radians(Some(PI * 2.0)), // + re_types::datatypes::AffixFuzzer3::Craziness(vec![ + re_types::datatypes::AffixFuzzer1 { + single_float_optional: Some(3.0), + single_string_required: "c".into(), + single_string_optional: Some("c".into()), + many_floats_optional: Some(vec![3.0, 30.0, 300.0]), + many_strings_required: vec!["5".into(), "6".into()], + many_strings_optional: Some(vec!["50".into(), "60".into()]), + flattened_scalar: 44.0, + almost_flattened_scalar: re_types::datatypes::FlattenedScalar { + value: 44.0, + }, + }, + ]), + ]), // + re_types::datatypes::AffixFuzzer4::ManyOptional(Some(vec![ + re_types::datatypes::AffixFuzzer3::Radians(None), + ])), // + re_types::datatypes::AffixFuzzer4::ManyOptional(None), // + ]), + }; + let arch = AffixFuzzer1::new( fuzzy1.clone(), fuzzy2.clone(), @@ -157,6 +258,11 @@ fn roundtrip() { fuzzy11_1.clone(), fuzzy12_1.clone(), fuzzy13_1.clone(), + fuzzy14_2.clone(), + // fuzzy15_1.clone(), + fuzzy16_2.clone(), + fuzzy17_2.clone(), + fuzzy18_2.clone(), [fuzzy1.clone(), fuzzy1.clone(), fuzzy1.clone()], [fuzzy2.clone(), fuzzy2.clone(), fuzzy2.clone()], [fuzzy3.clone(), fuzzy3.clone(), fuzzy3.clone()], @@ -170,16 +276,34 @@ fn roundtrip() { [fuzzy11_1.clone(), fuzzy11_2.clone(), fuzzy11_1.clone()], [fuzzy12_1.clone(), fuzzy12_2.clone(), fuzzy12_1.clone()], [fuzzy13_1.clone(), fuzzy13_2.clone(), fuzzy13_1.clone()], + [fuzzy14_1.clone(), fuzzy14_2.clone(), fuzzy14_3.clone()], + // [fuzzy15_1.clone(), fuzzy15_2.clone(), fuzzy15_1.clone()], + [fuzzy16_1.clone(), fuzzy16_2.clone(), fuzzy16_1.clone()], + [fuzzy17_1.clone(), fuzzy17_2.clone(), fuzzy17_1.clone()], + [fuzzy18_1.clone(), fuzzy18_2.clone(), fuzzy18_3.clone()], ) .with_fuzz2001(fuzzy1.clone()) .with_fuzz2003(fuzzy3.clone()) .with_fuzz2005(fuzzy5.clone()) + .with_fuzz2007(fuzzy7_1.clone()) + .with_fuzz2009(fuzzy9_1.clone()) + .with_fuzz2011(fuzzy11_1.clone()) + .with_fuzz2013(fuzzy13_1.clone()) + .with_fuzz2014(fuzzy14_3.clone()) + // .with_fuzz2015(fuzzy15_1.clone()) + .with_fuzz2016(fuzzy16_1.clone()) + .with_fuzz2017(fuzzy17_1.clone()) + .with_fuzz2018(fuzzy18_1.clone()) .with_fuzz2102([fuzzy2.clone(), fuzzy2.clone(), fuzzy2.clone()]) .with_fuzz2104([fuzzy4.clone(), fuzzy4.clone(), fuzzy4.clone()]) .with_fuzz2106([fuzzy6.clone(), fuzzy6.clone(), fuzzy6.clone()]) .with_fuzz2108([fuzzy8_1.clone(), fuzzy8_2.clone(), fuzzy8_1.clone()]) .with_fuzz2110([fuzzy10_1.clone(), fuzzy10_2.clone(), fuzzy10_1.clone()]) - .with_fuzz2112([fuzzy12_1.clone(), fuzzy12_2.clone(), fuzzy12_1.clone()]); + .with_fuzz2112([fuzzy12_1.clone(), fuzzy12_2.clone(), fuzzy12_1.clone()]) + .with_fuzz2114([fuzzy14_1.clone(), fuzzy14_2.clone(), fuzzy14_3.clone()]) + .with_fuzz2116([fuzzy16_1.clone(), fuzzy16_2.clone(), fuzzy16_1.clone()]) + .with_fuzz2117([fuzzy17_1.clone(), fuzzy17_2.clone(), fuzzy17_1.clone()]) + .with_fuzz2118([fuzzy18_1.clone(), fuzzy18_2.clone(), fuzzy18_3.clone()]); #[rustfmt::skip] let expected_extensions: HashMap<_, _> = [ diff --git a/crates/re_types_builder/src/codegen/rust.rs b/crates/re_types_builder/src/codegen/rust.rs index 8e0ec4ac0ecb..60c047109305 100644 --- a/crates/re_types_builder/src/codegen/rust.rs +++ b/crates/re_types_builder/src/codegen/rust.rs @@ -251,7 +251,7 @@ impl QuotedObject { let quoted_struct = if is_tuple_struct { quote! { pub struct #name(#(#quoted_fields,)*); } } else { - quote! { pub struct #name { #(#quoted_fields,)* } } + quote! { pub struct #name { #(#quoted_fields,)* }} }; let quoted_trait_impls = quote_trait_impls_from_obj(arrow_registry, objects, obj); @@ -315,15 +315,21 @@ impl QuotedObject { typ: _, attrs: _, order: _, - is_nullable: _, + is_nullable, is_deprecated: _, datatype: _, } = obj_field; - let name = format_ident!("{name}"); + use convert_case::{Case, Casing}; + let name = format_ident!("{}", name.to_case(Case::UpperCamel)); let quoted_doc = quote_doc_from_docs(docs); let (quoted_type, _) = quote_field_type_from_field(obj_field, false); + let quoted_type = if *is_nullable { + quote!(Option<#quoted_type>) + } else { + quoted_type + }; quote! { #quoted_doc @@ -974,7 +980,7 @@ impl quote::ToTokens for ArrowDataTypeTokenizer<'_> { UnionMode::Dense => quote!(UnionMode::Dense), UnionMode::Sparse => quote!(UnionMode::Sparse), }; - quote!(DataType::Union(#(#fields,)*, None, #mode)) + quote!(DataType::Union(vec![ #(#fields,)* ], None, #mode)) } DataType::Struct(fields) => { @@ -1132,7 +1138,7 @@ fn quote_arrow_serializer( let quoted_flatten = quoted_flatten(obj_field.is_nullable); - quote! { { + quote! {{ let (somes, #quoted_data_dst): (Vec<_>, Vec<_>) = #quoted_data_src .into_iter() .map(|datum| { @@ -1153,7 +1159,7 @@ fn quote_arrow_serializer( #quoted_bitmap; #quoted_serializer - } } + }} } else { let data_src = data_src.clone(); @@ -1176,7 +1182,7 @@ fn quote_arrow_serializer( let quoted_bitmap = quoted_bitmap(bitmap_dst); - quote! { { + quote! {{ let (somes, #data_dst): (Vec<_>, Vec<_>) = #data_src .iter() .map(|datum| { @@ -1196,12 +1202,12 @@ fn quote_arrow_serializer( #quoted_bitmap; #quoted_serializer - } } + }} }); let quoted_bitmap = quoted_bitmap(format_ident!("bitmap")); - quote! { { + quote! {{ let (somes, #data_src): (Vec<_>, Vec<_>) = #data_src .into_iter() .map(|datum| { @@ -1217,7 +1223,125 @@ fn quote_arrow_serializer( vec![#(#quoted_field_serializers,)*], bitmap, ).boxed() - } } + }} + } + DataType::Union(_, _, arrow2::datatypes::UnionMode::Dense) => { + let quoted_field_serializers = obj.fields.iter().map(|obj_field| { + let data_dst = format_ident!("{}", obj_field.name); + let bitmap_dst = format_ident!("{data_dst}_bitmap"); + + let quoted_serializer = quote_arrow_field_serializer( + None, + &arrow_registry.get(&obj_field.fqname), + obj_field.is_nullable, + &bitmap_dst, + &data_dst, + ); + + let quoted_flatten = quoted_flatten(obj_field.is_nullable); + let quoted_bitmap = quoted_bitmap(bitmap_dst); + + let quoted_obj_name = format_ident!("{}", obj.name); + let quoted_obj_field_name = { + use convert_case::{Case, Casing}; + format_ident!("{}", obj_field.name.to_case(Case::UpperCamel)) + }; + + quote! {{ + let (somes, #data_dst): (Vec<_>, Vec<_>) = #data_src + .iter() + .flatten() // NOTE: unions cannot ever be nullable at top-level + .filter(|datum| matches!(***datum, #quoted_obj_name::#quoted_obj_field_name(_))) + .map(|datum| { + let datum = match &**datum { + #quoted_obj_name::#quoted_obj_field_name(v) => Some(v.clone()), + _ => None, + } #quoted_flatten ; + + (datum.is_some(), datum) + }) + .unzip(); + + + #quoted_bitmap; + + #quoted_serializer + }} + }); + + let quoted_types = { + let quoted_obj_name = format_ident!("{}", obj.name); + let quoted_branches = obj.fields.iter().enumerate().map(|(i, obj_field)| { + let i = i as i8; + let quoted_obj_field_name = { + use convert_case::{Case, Casing}; + format_ident!("{}", obj_field.name.to_case(Case::UpperCamel)) + }; + quote!(#quoted_obj_name::#quoted_obj_field_name(_) => #i) + }); + + quote! {{ + #data_src + .iter() + .flatten() + .map(|v| match **v { + #(#quoted_branches,)* + }) + .collect() + }} + }; + + let quoted_offsets = { + let quoted_obj_name = format_ident!("{}", obj.name); + + let quoted_counters = obj.fields.iter().map(|obj_field| { + let quoted_obj_field_name = format_ident!("{}_offset", obj_field.name); + quote!(let mut #quoted_obj_field_name = 0) + }); + + let quoted_branches = obj.fields.iter().map(|obj_field| { + let quoted_counter_name = format_ident!("{}_offset", obj_field.name); + let quoted_obj_field_name = { + use convert_case::{Case, Casing}; + format_ident!("{}", obj_field.name.to_case(Case::UpperCamel)) + }; + quote! { + #quoted_obj_name::#quoted_obj_field_name(_) => { + let offset = #quoted_counter_name; + #quoted_counter_name += 1; + offset + } + } + }); + + quote! {{ + #(#quoted_counters;)* + #data_src + .iter() + .flatten() + .map(|v| match **v { + #(#quoted_branches,)* + }) + .collect() + }} + }; + + quote! {{ + let #data_src: Vec<_> = #data_src + .into_iter() + .map(|datum| { + let datum: Option<::std::borrow::Cow<'a, Self>> = datum.map(Into::into); + datum + }) + .collect(); + + UnionArray::new( + #quoted_datatype, + #quoted_types, + vec![#(#quoted_field_serializers,)*], + Some(#quoted_offsets), + ).boxed() + }} } _ => unimplemented!("{datatype:#?}"), // NOLINT } @@ -1269,7 +1393,7 @@ fn quote_arrow_field_serializer( } DataType::Utf8 => { - quote! { { + quote! {{ // NOTE: Flattening to remove the guaranteed layer of nullability: we don't care // about it while building the backing buffer since it's all offsets driven. let inner_data: ::arrow2::buffer::Buffer = #data_src.iter().flatten().flat_map(|s| s.bytes()).collect(); @@ -1282,7 +1406,7 @@ fn quote_arrow_field_serializer( // whole utf8 validation _again_. #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked(#quoted_datatype, offsets, inner_data, #bitmap_src) }.boxed() - } } + }} } DataType::List(inner) | DataType::FixedSizeList(inner, _) => { @@ -1325,7 +1449,7 @@ fn quote_arrow_field_serializer( // TODO(cmc): We should be checking this, but right now we don't because we don't // support intra-list nullability. _ = is_nullable; - quote! { { + quote! {{ use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let #quoted_inner_data: Vec<_> = #data_src @@ -1347,10 +1471,10 @@ fn quote_arrow_field_serializer( }; #quoted_create - } } + }} } - DataType::Struct(_) => { + DataType::Struct(_) | DataType::Union(_, _, _) => { // NOTE: We always wrap objects with full extension metadata. let DataType::Extension(fqname, _, _) = datatype else { unreachable!() }; let fqname_use = quote_fqname_as_type_path(fqname); @@ -1471,7 +1595,7 @@ fn quote_arrow_deserializer( } }); - quote! { { + quote! {{ let #data_src = #data_src .as_any() .downcast_ref::<::arrow2::array::StructArray>() @@ -1500,8 +1624,93 @@ fn quote_arrow_deserializer( })).transpose()) // NOTE: implicit Vec to Result .collect::>>()? - } } + }} + } + + DataType::Union(_, _, arrow2::datatypes::UnionMode::Dense) => { + let data_src_types = format_ident!("{data_src}_types"); + let data_src_arrays = format_ident!("{data_src}_arrays"); + let data_src_offsets = format_ident!("{data_src}_offsets"); + + let quoted_field_deserializers = + obj.fields.iter().enumerate().map(|(i, obj_field)| { + let data_dst = format_ident!("{}", obj_field.name); + + let quoted_deserializer = quote_arrow_field_deserializer( + &arrow_registry.get(&obj_field.fqname), + obj_field.is_nullable, + &data_src, + ); + + quote! { + let #data_dst = { + let #data_src = &*#data_src_arrays[#i]; + #quoted_deserializer.collect::>() + } + } + }); + + let quoted_obj_name = format_ident!("{}", obj.name); + let quoted_branches = obj.fields.iter().enumerate().map(|(i, obj_field)| { + let i = i as i8; + let quoted_obj_field_name = format_ident!("{}", obj_field.name); + let quoted_obj_field_type = { + use convert_case::{Case, Casing}; + format_ident!("{}", obj_field.name.to_case(Case::UpperCamel)) + }; + + let quoted_unwrap = if obj_field.is_nullable { + quote!() + } else { + quote!(.unwrap()) + }; + + quote! { + #i => #quoted_obj_name::#quoted_obj_field_type( + #quoted_obj_field_name + .get(offset as usize) + .ok_or_else(|| crate::DeserializationError::OffsetsMismatch { + bounds: (offset as usize, offset as usize), + len: #quoted_obj_field_name.len(), + datatype: #data_src.data_type().clone(), + })? + .clone() + #quoted_unwrap + ) + } + }); + + quote! {{ + let #data_src = #data_src + .as_any() + .downcast_ref::<::arrow2::array::UnionArray>() + .ok_or_else(|| crate::DeserializationError::SchemaMismatch { + expected: #data_src.data_type().clone(), + got: #data_src.data_type().clone(), + })?; + + let (#data_src_types, #data_src_arrays, #data_src_offsets) = + // NOTE: unwrapping of offsets is safe because this is a dense union + (#data_src.types(), #data_src.fields(), #data_src.offsets().unwrap()); + + #(#quoted_field_deserializers;)* + + #data_src_types + .iter() + .enumerate() + .map(|(i, typ)| { + let offset = #data_src_offsets[i]; + + Ok(Some(match typ { + #(#quoted_branches,)* + _ => unreachable!(), + })) + }) + // NOTE: implicit Vec to Result + .collect::>>()? + }} } + _ => unimplemented!("{datatype:#?}"), // NOLINT } } @@ -1555,7 +1764,7 @@ fn quote_arrow_field_deserializer( let quoted_inner = quote_arrow_field_deserializer(inner_datatype, inner.is_nullable, data_src); - quote! { { + quote! {{ let datatype = #data_src.data_type(); let #data_src = #data_src .as_any() @@ -1595,7 +1804,7 @@ fn quote_arrow_field_deserializer( // NOTE: implicit Vec to Result .collect::>>>()? .into_iter() - } } + }} } DataType::List(inner) => { @@ -1605,7 +1814,7 @@ fn quote_arrow_field_deserializer( let quoted_inner = quote_arrow_field_deserializer(inner_datatype, inner.is_nullable, data_src); - quote! { { + quote! {{ let datatype = #data_src.data_type(); let #data_src = #data_src .as_any() @@ -1643,10 +1852,10 @@ fn quote_arrow_field_deserializer( // NOTE: implicit Vec to Result .collect::>>>()? .into_iter() - } } + }} } - DataType::Struct(_) => { + DataType::Struct(_) | DataType::Union(_, _, _) => { let DataType::Extension(fqname, _, _) = datatype else { unreachable!() }; let fqname_use = quote_fqname_as_type_path(fqname); quote!(#fqname_use::try_from_arrow_opt(#data_src)?.into_iter()) diff --git a/crates/re_types_builder/src/objects.rs b/crates/re_types_builder/src/objects.rs index d07a0a564fce..dd0920fea003 100644 --- a/crates/re_types_builder/src/objects.rs +++ b/crates/re_types_builder/src/objects.rs @@ -64,12 +64,12 @@ impl Objects { let mut done = false; while !done { done = true; - let mut objects_copy = this.objects.clone(); // borrowck, the lazy way + let objects_copy = this.objects.clone(); // borrowck, the lazy way for obj in this.objects.values_mut() { for field in &mut obj.fields { if field.is_transparent() { if let Some(target_fqname) = field.typ.fqname() { - let mut target_obj = objects_copy.remove(target_fqname).unwrap(); + let mut target_obj = objects_copy[target_fqname].clone(); assert!( target_obj.fields.len() == 1, "field '{}' is marked transparent but points to object '{}' which \ @@ -125,6 +125,24 @@ impl Objects { .filter(|(_, obj)| !obj.is_transparent()) .collect(); + // Check for nullable unions -- these cannot be represented in Arrow! + for obj in this.objects.values() { + for field in &obj.fields { + if !field.is_nullable { + continue; + } + + if let Type::Object(fqname) = &field.typ { + let target = &this.objects[fqname]; + assert!( + !(target.is_enum() || target.is_union()), + "nullable unions cannot be represented in Arrow, found one at {:?}", + field.fqname, + ); + } + } + } + this } } @@ -411,6 +429,7 @@ impl Object { .iter() // NOTE: These are intermediate fields used by flatbuffers internals, we don't care. .filter(|field| field.type_().base_type() != FbsBaseType::UType) + .filter(|field| field.type_().element() != FbsBaseType::UType) .map(|field| { ObjectField::from_raw_object_field(include_dir_path, enums, objs, obj, &field) }) @@ -923,7 +942,7 @@ pub enum ElementType { impl ElementType { pub fn from_raw_base_type( - _enums: &[FbsEnum<'_>], + enums: &[FbsEnum<'_>], objs: &[FbsObject<'_>], outer_type: FbsType<'_>, inner_type: FbsBaseType, @@ -946,12 +965,15 @@ impl ElementType { let obj = &objs[outer_type.index() as usize]; Self::Object(obj.name().to_owned()) } - FbsBaseType::Union => unimplemented!("{inner_type:#?}"), // NOLINT + FbsBaseType::Union => { + let enm = &enums[outer_type.index() as usize]; + Self::Object(enm.name().to_owned()) + } FbsBaseType::None | FbsBaseType::UType | FbsBaseType::Array | FbsBaseType::Vector - | FbsBaseType::Vector64 => unreachable!("{inner_type:#?}"), + | FbsBaseType::Vector64 => unreachable!("{outer_type:#?} into {inner_type:#?}"), // NOTE: `FbsType` isn't actually an enum, it's just a bunch of constants... _ => unreachable!("{inner_type:#?}"), } diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py index ce6276757eaa..1546e3cbffdf 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/archetypes/fuzzy.py @@ -66,6 +66,22 @@ class AffixFuzzer1(Archetype): metadata={"component": "primary"}, converter=components.AffixFuzzer13Array.from_similar, # type: ignore[misc] ) + fuzz1014: components.AffixFuzzer14Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer14Array.from_similar, # type: ignore[misc] + ) + fuzz1016: components.AffixFuzzer16Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer16Array.from_similar, # type: ignore[misc] + ) + fuzz1017: components.AffixFuzzer17Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer17Array.from_similar, # type: ignore[misc] + ) + fuzz1018: components.AffixFuzzer18Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer18Array.from_similar, # type: ignore[misc] + ) fuzz1101: components.AffixFuzzer1Array = field( metadata={"component": "primary"}, converter=components.AffixFuzzer1Array.from_similar, # type: ignore[misc] @@ -118,6 +134,22 @@ class AffixFuzzer1(Archetype): metadata={"component": "primary"}, converter=components.AffixFuzzer13Array.from_similar, # type: ignore[misc] ) + fuzz1114: components.AffixFuzzer14Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer14Array.from_similar, # type: ignore[misc] + ) + fuzz1116: components.AffixFuzzer16Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer16Array.from_similar, # type: ignore[misc] + ) + fuzz1117: components.AffixFuzzer17Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer17Array.from_similar, # type: ignore[misc] + ) + fuzz1118: components.AffixFuzzer18Array = field( + metadata={"component": "primary"}, + converter=components.AffixFuzzer18Array.from_similar, # type: ignore[misc] + ) fuzz2001: components.AffixFuzzer1Array | None = field( metadata={"component": "secondary"}, default=None, @@ -183,6 +215,26 @@ class AffixFuzzer1(Archetype): default=None, converter=components.AffixFuzzer13Array.from_similar, # type: ignore[misc] ) + fuzz2014: components.AffixFuzzer14Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer14Array.from_similar, # type: ignore[misc] + ) + fuzz2016: components.AffixFuzzer16Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer16Array.from_similar, # type: ignore[misc] + ) + fuzz2017: components.AffixFuzzer17Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer17Array.from_similar, # type: ignore[misc] + ) + fuzz2018: components.AffixFuzzer18Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer18Array.from_similar, # type: ignore[misc] + ) fuzz2101: components.AffixFuzzer1Array | None = field( metadata={"component": "secondary"}, default=None, @@ -248,5 +300,25 @@ class AffixFuzzer1(Archetype): default=None, converter=components.AffixFuzzer13Array.from_similar, # type: ignore[misc] ) + fuzz2114: components.AffixFuzzer14Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer14Array.from_similar, # type: ignore[misc] + ) + fuzz2116: components.AffixFuzzer16Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer16Array.from_similar, # type: ignore[misc] + ) + fuzz2117: components.AffixFuzzer17Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer17Array.from_similar, # type: ignore[misc] + ) + fuzz2118: components.AffixFuzzer18Array | None = field( + metadata={"component": "secondary"}, + default=None, + converter=components.AffixFuzzer18Array.from_similar, # type: ignore[misc] + ) __str__ = Archetype.__str__ __repr__ = Archetype.__repr__ diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py index 2f3c5b4701d4..e3fb8b3e5be7 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/__init__.py @@ -53,6 +53,23 @@ AffixFuzzer13ArrayLike, AffixFuzzer13Like, AffixFuzzer13Type, + AffixFuzzer14Array, + AffixFuzzer14Type, + AffixFuzzer16, + AffixFuzzer16Array, + AffixFuzzer16ArrayLike, + AffixFuzzer16Like, + AffixFuzzer16Type, + AffixFuzzer17, + AffixFuzzer17Array, + AffixFuzzer17ArrayLike, + AffixFuzzer17Like, + AffixFuzzer17Type, + AffixFuzzer18, + AffixFuzzer18Array, + AffixFuzzer18ArrayLike, + AffixFuzzer18Like, + AffixFuzzer18Type, ) from .instance_key import InstanceKey, InstanceKeyArray, InstanceKeyArrayLike, InstanceKeyLike, InstanceKeyType from .keypoint_id import KeypointId, KeypointIdArray, KeypointIdArrayLike, KeypointIdLike, KeypointIdType @@ -81,6 +98,23 @@ "AffixFuzzer13ArrayLike", "AffixFuzzer13Like", "AffixFuzzer13Type", + "AffixFuzzer14Array", + "AffixFuzzer14Type", + "AffixFuzzer16", + "AffixFuzzer16Array", + "AffixFuzzer16ArrayLike", + "AffixFuzzer16Like", + "AffixFuzzer16Type", + "AffixFuzzer17", + "AffixFuzzer17Array", + "AffixFuzzer17ArrayLike", + "AffixFuzzer17Like", + "AffixFuzzer17Type", + "AffixFuzzer18", + "AffixFuzzer18Array", + "AffixFuzzer18ArrayLike", + "AffixFuzzer18Like", + "AffixFuzzer18Type", "AffixFuzzer1Array", "AffixFuzzer1Type", "AffixFuzzer2Array", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py index 734bce377269..738cd66f05c1 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/components/fuzzy.py @@ -41,6 +41,23 @@ "AffixFuzzer13ArrayLike", "AffixFuzzer13Like", "AffixFuzzer13Type", + "AffixFuzzer14Array", + "AffixFuzzer14Type", + "AffixFuzzer16", + "AffixFuzzer16Array", + "AffixFuzzer16ArrayLike", + "AffixFuzzer16Like", + "AffixFuzzer16Type", + "AffixFuzzer17", + "AffixFuzzer17Array", + "AffixFuzzer17ArrayLike", + "AffixFuzzer17Like", + "AffixFuzzer17Type", + "AffixFuzzer18", + "AffixFuzzer18Array", + "AffixFuzzer18ArrayLike", + "AffixFuzzer18Like", + "AffixFuzzer18Type", "AffixFuzzer1Array", "AffixFuzzer1Type", "AffixFuzzer2Array", @@ -464,3 +481,466 @@ def _native_to_pa_array(data: AffixFuzzer13ArrayLike, data_type: pa.DataType) -> # TODO(cmc): bring back registration to pyarrow once legacy types are gone # pa.register_extension_type(AffixFuzzer13Type()) + + +class AffixFuzzer14Type(BaseDelegatingExtensionType): + _TYPE_NAME = "rerun.testing.components.AffixFuzzer14" + _DELEGATED_EXTENSION_TYPE = datatypes.AffixFuzzer3Type + + +class AffixFuzzer14Array(BaseDelegatingExtensionArray[datatypes.AffixFuzzer3ArrayLike]): + _EXTENSION_NAME = "rerun.testing.components.AffixFuzzer14" + _EXTENSION_TYPE = AffixFuzzer14Type + _DELEGATED_ARRAY_TYPE = datatypes.AffixFuzzer3Array + + +AffixFuzzer14Type._ARRAY_TYPE = AffixFuzzer14Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer14Type()) + + +@define +class AffixFuzzer16: + many_required_unions: list[datatypes.AffixFuzzer3] = field() + + +AffixFuzzer16Like = AffixFuzzer16 +AffixFuzzer16ArrayLike = Union[ + AffixFuzzer16, + Sequence[AffixFuzzer16Like], +] + + +# --- Arrow support --- + + +class AffixFuzzer16Type(BaseExtensionType): + def __init__(self) -> None: + pa.ExtensionType.__init__( + self, + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + "rerun.testing.components.AffixFuzzer16", + ) + + +class AffixFuzzer16Array(BaseExtensionArray[AffixFuzzer16ArrayLike]): + _EXTENSION_NAME = "rerun.testing.components.AffixFuzzer16" + _EXTENSION_TYPE = AffixFuzzer16Type + + @staticmethod + def _native_to_pa_array(data: AffixFuzzer16ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError + + +AffixFuzzer16Type._ARRAY_TYPE = AffixFuzzer16Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer16Type()) + + +@define +class AffixFuzzer17: + many_optional_unions: list[datatypes.AffixFuzzer3] | None = field(default=None) + + +AffixFuzzer17Like = AffixFuzzer17 +AffixFuzzer17ArrayLike = Union[ + AffixFuzzer17, + Sequence[AffixFuzzer17Like], +] + + +# --- Arrow support --- + + +class AffixFuzzer17Type(BaseExtensionType): + def __init__(self) -> None: + pa.ExtensionType.__init__( + self, + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + True, + {}, + ) + ), + "rerun.testing.components.AffixFuzzer17", + ) + + +class AffixFuzzer17Array(BaseExtensionArray[AffixFuzzer17ArrayLike]): + _EXTENSION_NAME = "rerun.testing.components.AffixFuzzer17" + _EXTENSION_TYPE = AffixFuzzer17Type + + @staticmethod + def _native_to_pa_array(data: AffixFuzzer17ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError + + +AffixFuzzer17Type._ARRAY_TYPE = AffixFuzzer17Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer17Type()) + + +@define +class AffixFuzzer18: + many_optional_unions: list[datatypes.AffixFuzzer4] | None = field(default=None) + + +AffixFuzzer18Like = AffixFuzzer18 +AffixFuzzer18ArrayLike = Union[ + AffixFuzzer18, + Sequence[AffixFuzzer18Like], +] + + +# --- Arrow support --- + + +class AffixFuzzer18Type(BaseExtensionType): + def __init__(self) -> None: + pa.ExtensionType.__init__( + self, + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field( + "single_required", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + False, + {}, + ), + pa.field( + "many_required", + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field( + "single_float_optional", pa.float32(), True, {} + ), + pa.field( + "single_string_required", pa.utf8(), False, {} + ), + pa.field( + "single_string_optional", pa.utf8(), True, {} + ), + pa.field( + "many_floats_optional", + pa.list_( + pa.field("item", pa.float32(), True, {}) + ), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_( + pa.field("item", pa.utf8(), False, {}) + ), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field( + "flattened_scalar", pa.float32(), False, {} + ), + pa.field( + "almost_flattened_scalar", + pa.struct( + [pa.field("value", pa.float32(), False, {})] + ), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + pa.field( + "many_optional", + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field( + "single_float_optional", pa.float32(), True, {} + ), + pa.field( + "single_string_required", pa.utf8(), False, {} + ), + pa.field( + "single_string_optional", pa.utf8(), True, {} + ), + pa.field( + "many_floats_optional", + pa.list_( + pa.field("item", pa.float32(), True, {}) + ), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_( + pa.field("item", pa.utf8(), False, {}) + ), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field( + "flattened_scalar", pa.float32(), False, {} + ), + pa.field( + "almost_flattened_scalar", + pa.struct( + [pa.field("value", pa.float32(), False, {})] + ), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + True, + {}, + ) + ), + False, + {}, + ), + ] + ), + True, + {}, + ) + ), + "rerun.testing.components.AffixFuzzer18", + ) + + +class AffixFuzzer18Array(BaseExtensionArray[AffixFuzzer18ArrayLike]): + _EXTENSION_NAME = "rerun.testing.components.AffixFuzzer18" + _EXTENSION_TYPE = AffixFuzzer18Type + + @staticmethod + def _native_to_pa_array(data: AffixFuzzer18ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError + + +AffixFuzzer18Type._ARRAY_TYPE = AffixFuzzer18Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer18Type()) diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py index 6881e833958a..a841548e06bd 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/__init__.py @@ -13,6 +13,16 @@ AffixFuzzer2ArrayLike, AffixFuzzer2Like, AffixFuzzer2Type, + AffixFuzzer3, + AffixFuzzer3Array, + AffixFuzzer3ArrayLike, + AffixFuzzer3Like, + AffixFuzzer3Type, + AffixFuzzer4, + AffixFuzzer4Array, + AffixFuzzer4ArrayLike, + AffixFuzzer4Like, + AffixFuzzer4Type, FlattenedScalar, FlattenedScalarArray, FlattenedScalarArrayLike, @@ -33,6 +43,16 @@ "AffixFuzzer2ArrayLike", "AffixFuzzer2Like", "AffixFuzzer2Type", + "AffixFuzzer3", + "AffixFuzzer3Array", + "AffixFuzzer3ArrayLike", + "AffixFuzzer3Like", + "AffixFuzzer3Type", + "AffixFuzzer4", + "AffixFuzzer4Array", + "AffixFuzzer4ArrayLike", + "AffixFuzzer4Like", + "AffixFuzzer4Type", "FlattenedScalar", "FlattenedScalarArray", "FlattenedScalarArrayLike", diff --git a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py index 6a69a09ed79a..9428ae131a66 100644 --- a/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py +++ b/rerun_py/rerun_sdk/rerun/_rerun2/datatypes/fuzzy.py @@ -29,6 +29,16 @@ "AffixFuzzer2ArrayLike", "AffixFuzzer2Like", "AffixFuzzer2Type", + "AffixFuzzer3", + "AffixFuzzer3Array", + "AffixFuzzer3ArrayLike", + "AffixFuzzer3Like", + "AffixFuzzer3Type", + "AffixFuzzer4", + "AffixFuzzer4Array", + "AffixFuzzer4ArrayLike", + "AffixFuzzer4Like", + "AffixFuzzer4Type", "FlattenedScalar", "FlattenedScalarArray", "FlattenedScalarArrayLike", @@ -175,3 +185,316 @@ def _native_to_pa_array(data: AffixFuzzer2ArrayLike, data_type: pa.DataType) -> # TODO(cmc): bring back registration to pyarrow once legacy types are gone # pa.register_extension_type(AffixFuzzer2Type()) + + +@define +class AffixFuzzer4: + single_required: datatypes.AffixFuzzer3 | None = None + many_required: list[datatypes.AffixFuzzer3] | None = None + many_optional: list[datatypes.AffixFuzzer3] | None = None + + +AffixFuzzer4Like = AffixFuzzer4 +AffixFuzzer4ArrayLike = Union[ + AffixFuzzer4, + Sequence[AffixFuzzer4Like], +] + + +# --- Arrow support --- + + +class AffixFuzzer4Type(BaseExtensionType): + def __init__(self) -> None: + pa.ExtensionType.__init__( + self, + pa.dense_union( + [ + pa.field( + "single_required", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + False, + {}, + ), + pa.field( + "many_required", + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + pa.field( + "many_optional", + pa.list_( + pa.field( + "item", + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + True, + {}, + ) + ), + False, + {}, + ), + ] + ), + "rerun.testing.datatypes.AffixFuzzer4", + ) + + +class AffixFuzzer4Array(BaseExtensionArray[AffixFuzzer4ArrayLike]): + _EXTENSION_NAME = "rerun.testing.datatypes.AffixFuzzer4" + _EXTENSION_TYPE = AffixFuzzer4Type + + @staticmethod + def _native_to_pa_array(data: AffixFuzzer4ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError + + +AffixFuzzer4Type._ARRAY_TYPE = AffixFuzzer4Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer4Type()) + + +@define +class AffixFuzzer3: + degrees: float | None = None + radians: float | None = None + craziness: list[datatypes.AffixFuzzer1] | None = None + + +AffixFuzzer3Like = AffixFuzzer3 +AffixFuzzer3ArrayLike = Union[ + AffixFuzzer3, + Sequence[AffixFuzzer3Like], +] + + +# --- Arrow support --- + + +class AffixFuzzer3Type(BaseExtensionType): + def __init__(self) -> None: + pa.ExtensionType.__init__( + self, + pa.dense_union( + [ + pa.field("degrees", pa.float32(), False, {}), + pa.field("radians", pa.float32(), False, {}), + pa.field( + "craziness", + pa.list_( + pa.field( + "item", + pa.struct( + [ + pa.field("single_float_optional", pa.float32(), True, {}), + pa.field("single_string_required", pa.utf8(), False, {}), + pa.field("single_string_optional", pa.utf8(), True, {}), + pa.field( + "many_floats_optional", + pa.list_(pa.field("item", pa.float32(), True, {})), + True, + {}, + ), + pa.field( + "many_strings_required", + pa.list_(pa.field("item", pa.utf8(), False, {})), + False, + {}, + ), + pa.field( + "many_strings_optional", + pa.list_(pa.field("item", pa.utf8(), True, {})), + True, + {}, + ), + pa.field("flattened_scalar", pa.float32(), False, {}), + pa.field( + "almost_flattened_scalar", + pa.struct([pa.field("value", pa.float32(), False, {})]), + False, + {}, + ), + ] + ), + False, + {}, + ) + ), + False, + {}, + ), + ] + ), + "rerun.testing.datatypes.AffixFuzzer3", + ) + + +class AffixFuzzer3Array(BaseExtensionArray[AffixFuzzer3ArrayLike]): + _EXTENSION_NAME = "rerun.testing.datatypes.AffixFuzzer3" + _EXTENSION_TYPE = AffixFuzzer3Type + + @staticmethod + def _native_to_pa_array(data: AffixFuzzer3ArrayLike, data_type: pa.DataType) -> pa.Array: + raise NotImplementedError + + +AffixFuzzer3Type._ARRAY_TYPE = AffixFuzzer3Array + +# TODO(cmc): bring back registration to pyarrow once legacy types are gone +# pa.register_extension_type(AffixFuzzer3Type()) diff --git a/scripts/ci/check_large_files_allow_list.txt b/scripts/ci/check_large_files_allow_list.txt index 5a7f3fe8db28..7fb9c28549de 100644 --- a/scripts/ci/check_large_files_allow_list.txt +++ b/scripts/ci/check_large_files_allow_list.txt @@ -1,4 +1,6 @@ Cargo.lock +crates/re_types/src/archetypes/fuzzy.rs crates/re_types/src/components/fuzzy.rs +crates/re_types/src/datatypes/fuzzy.rs crates/re_types_builder/src/reflection.rs crates/re_ui/data/Inter-Medium.otf