From f7ea2bb4acbed5c0bfcfcde34979b11a9a1cecf6 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 13 May 2024 12:58:29 +0200 Subject: [PATCH] Remove some clones in the generated arrow serializer (#6249) ### What No huge wins ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6249?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6249?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6249) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`. --- .../components/entity_properties_component.rs | 2 +- .../src/blueprint/components/active_tab.rs | 10 +- .../blueprint/components/included_content.rs | 10 +- .../blueprint/components/query_expression.rs | 10 +- .../blueprint/components/space_view_class.rs | 10 +- .../blueprint/components/space_view_origin.rs | 10 +- .../src/components/annotation_context.rs | 4 +- crates/re_types/src/components/blob.rs | 14 +- .../re_types/src/components/half_sizes2d.rs | 2 +- .../re_types/src/components/half_sizes3d.rs | 2 +- .../re_types/src/components/line_strip2d.rs | 8 +- .../re_types/src/components/line_strip3d.rs | 8 +- crates/re_types/src/components/media_type.rs | 10 +- crates/re_types/src/components/name.rs | 10 +- .../src/components/pinhole_projection.rs | 2 +- crates/re_types/src/components/position2d.rs | 2 +- crates/re_types/src/components/position3d.rs | 2 +- crates/re_types/src/components/range1d.rs | 2 +- crates/re_types/src/components/resolution.rs | 2 +- crates/re_types/src/components/texcoord2d.rs | 2 +- crates/re_types/src/components/text.rs | 10 +- .../re_types/src/components/text_log_level.rs | 10 +- .../src/components/triangle_indices.rs | 2 +- crates/re_types/src/components/vector2d.rs | 2 +- crates/re_types/src/components/vector3d.rs | 2 +- .../src/components/view_coordinates.rs | 4 +- .../re_types/src/datatypes/annotation_info.rs | 10 +- .../src/datatypes/class_description.rs | 30 ++-- crates/re_types/src/datatypes/mat3x3.rs | 4 +- crates/re_types/src/datatypes/mat4x4.rs | 4 +- crates/re_types/src/datatypes/quaternion.rs | 4 +- crates/re_types/src/datatypes/range1d.rs | 4 +- crates/re_types/src/datatypes/range2d.rs | 4 +- crates/re_types/src/datatypes/rotation3d.rs | 4 +- .../src/datatypes/rotation_axis_angle.rs | 2 +- crates/re_types/src/datatypes/scale3d.rs | 7 +- .../re_types/src/datatypes/tensor_buffer.rs | 140 +++++++++--------- crates/re_types/src/datatypes/tensor_data.rs | 6 +- .../src/datatypes/tensor_dimension.rs | 4 +- .../src/datatypes/translation_and_mat3x3.rs | 4 +- .../datatypes/translation_rotation_scale3d.rs | 2 +- crates/re_types/src/datatypes/uuid.rs | 4 +- crates/re_types/src/datatypes/uvec2d.rs | 4 +- crates/re_types/src/datatypes/uvec3d.rs | 4 +- crates/re_types/src/datatypes/uvec4d.rs | 4 +- crates/re_types/src/datatypes/vec2d.rs | 4 +- crates/re_types/src/datatypes/vec3d.rs | 4 +- crates/re_types/src/datatypes/vec4d.rs | 4 +- .../src/testing/components/affix_fuzzer10.rs | 4 +- .../src/testing/components/affix_fuzzer11.rs | 14 +- .../src/testing/components/affix_fuzzer12.rs | 8 +- .../src/testing/components/affix_fuzzer13.rs | 8 +- .../src/testing/components/affix_fuzzer16.rs | 4 +- .../src/testing/components/affix_fuzzer17.rs | 4 +- .../src/testing/components/affix_fuzzer18.rs | 4 +- .../src/testing/components/affix_fuzzer7.rs | 4 +- .../src/testing/components/affix_fuzzer9.rs | 4 +- .../src/testing/datatypes/affix_fuzzer1.rs | 86 +++++------ .../src/testing/datatypes/affix_fuzzer20.rs | 10 +- .../src/testing/datatypes/affix_fuzzer21.rs | 14 +- .../src/testing/datatypes/affix_fuzzer22.rs | 4 +- .../src/testing/datatypes/affix_fuzzer3.rs | 8 +- .../src/testing/datatypes/affix_fuzzer4.rs | 6 +- .../src/testing/datatypes/string_component.rs | 4 +- .../components/included_space_view.rs | 2 +- .../blueprint/components/root_container.rs | 2 +- .../components/space_view_maximized.rs | 2 +- .../src/codegen/rust/serializer.rs | 87 ++++++----- crates/re_types_core/src/arrow_buffer.rs | 5 + .../src/components/visualizer_overrides.rs | 8 +- .../src/datatypes/entity_path.rs | 4 +- crates/re_types_core/src/datatypes/utf8.rs | 4 +- .../src/datatypes/visible_time_range.rs | 10 +- 73 files changed, 367 insertions(+), 352 deletions(-) diff --git a/crates/re_entity_db/src/blueprint/components/entity_properties_component.rs b/crates/re_entity_db/src/blueprint/components/entity_properties_component.rs index 055f77e578e8..6b334e550aed 100644 --- a/crates/re_entity_db/src/blueprint/components/entity_properties_component.rs +++ b/crates/re_entity_db/src/blueprint/components/entity_properties_component.rs @@ -86,7 +86,7 @@ impl ::re_types_core::Loggable for EntityPropertiesComponent { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let buffers: Vec>> = data0 - .iter() + .into_iter() .map(|opt| { use ::re_types_core::SerializationError; opt.as_ref() diff --git a/crates/re_types/src/blueprint/components/active_tab.rs b/crates/re_types/src/blueprint/components/active_tab.rs index 18eaa9003916..9d7217d64dea 100644 --- a/crates/re_types/src/blueprint/components/active_tab.rs +++ b/crates/re_types/src/blueprint/components/active_tab.rs @@ -105,11 +105,6 @@ impl ::re_types_core::Loggable for ActiveTab { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -117,6 +112,11 @@ impl ::re_types_core::Loggable for ActiveTab { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/blueprint/components/included_content.rs b/crates/re_types/src/blueprint/components/included_content.rs index 8539be49109d..09052f8f5e88 100644 --- a/crates/re_types/src/blueprint/components/included_content.rs +++ b/crates/re_types/src/blueprint/components/included_content.rs @@ -106,11 +106,6 @@ impl ::re_types_core::Loggable for IncludedContent { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -118,6 +113,11 @@ impl ::re_types_core::Loggable for IncludedContent { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/blueprint/components/query_expression.rs b/crates/re_types/src/blueprint/components/query_expression.rs index 1ee8e30a5e24..bf8b25fe46f7 100644 --- a/crates/re_types/src/blueprint/components/query_expression.rs +++ b/crates/re_types/src/blueprint/components/query_expression.rs @@ -110,11 +110,6 @@ impl ::re_types_core::Loggable for QueryExpression { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -122,6 +117,11 @@ impl ::re_types_core::Loggable for QueryExpression { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/blueprint/components/space_view_class.rs b/crates/re_types/src/blueprint/components/space_view_class.rs index 8d59a953e414..c448935b5d1a 100644 --- a/crates/re_types/src/blueprint/components/space_view_class.rs +++ b/crates/re_types/src/blueprint/components/space_view_class.rs @@ -101,11 +101,6 @@ impl ::re_types_core::Loggable for SpaceViewClass { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -113,6 +108,11 @@ impl ::re_types_core::Loggable for SpaceViewClass { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/blueprint/components/space_view_origin.rs b/crates/re_types/src/blueprint/components/space_view_origin.rs index 442ca53d9381..88bbb94dc65e 100644 --- a/crates/re_types/src/blueprint/components/space_view_origin.rs +++ b/crates/re_types/src/blueprint/components/space_view_origin.rs @@ -101,11 +101,6 @@ impl ::re_types_core::Loggable for SpaceViewOrigin { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -113,6 +108,11 @@ impl ::re_types_core::Loggable for SpaceViewOrigin { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/components/annotation_context.rs b/crates/re_types/src/components/annotation_context.rs index 9f801d796ab7..7a4d93bb6e51 100644 --- a/crates/re_types/src/components/annotation_context.rs +++ b/crates/re_types/src/components/annotation_context.rs @@ -100,8 +100,6 @@ impl ::re_types_core::Loggable for AnnotationContext { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -109,6 +107,8 @@ impl ::re_types_core::Loggable for AnnotationContext { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/components/blob.rs b/crates/re_types/src/components/blob.rs index 590cccdf78a3..32eb3d3dcd77 100644 --- a/crates/re_types/src/components/blob.rs +++ b/crates/re_types/src/components/blob.rs @@ -98,6 +98,13 @@ impl ::re_types_core::Loggable for Blob { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + data0 + .iter() + .map(|opt| opt.as_ref().map_or(0, |datum| datum.num_instances())), + ) + .unwrap() + .into(); let data0_inner_data: Buffer<_> = data0 .iter() .flatten() @@ -106,13 +113,6 @@ impl ::re_types_core::Loggable for Blob { .concat() .into(); let data0_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - data0 - .iter() - .map(|opt| opt.as_ref().map_or(0, |datum| datum.num_instances())), - ) - .unwrap() - .into(); ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/components/half_sizes2d.rs b/crates/re_types/src/components/half_sizes2d.rs index 490908bb48b9..bca77299130f 100644 --- a/crates/re_types/src/components/half_sizes2d.rs +++ b/crates/re_types/src/components/half_sizes2d.rs @@ -108,7 +108,7 @@ impl ::re_types_core::Loggable for HalfSizes2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/half_sizes3d.rs b/crates/re_types/src/components/half_sizes3d.rs index 098da9666b7f..0c3e52b0fe0e 100644 --- a/crates/re_types/src/components/half_sizes3d.rs +++ b/crates/re_types/src/components/half_sizes3d.rs @@ -108,7 +108,7 @@ impl ::re_types_core::Loggable for HalfSizes3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/line_strip2d.rs b/crates/re_types/src/components/line_strip2d.rs index 3fd4b34dd198..6a0b6211ce6d 100644 --- a/crates/re_types/src/components/line_strip2d.rs +++ b/crates/re_types/src/components/line_strip2d.rs @@ -100,8 +100,6 @@ impl ::re_types_core::Loggable for LineStrip2D { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -109,14 +107,16 @@ impl ::re_types_core::Loggable for LineStrip2D { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data_inner_data: Vec<_> = data0_inner_data - .iter() - .map(|datum| datum.0.clone()) + .into_iter() + .map(|datum| datum.0) .flatten() .collect(); let data0_inner_data_inner_bitmap: Option = None; diff --git a/crates/re_types/src/components/line_strip3d.rs b/crates/re_types/src/components/line_strip3d.rs index 97012545c40d..305128390ad1 100644 --- a/crates/re_types/src/components/line_strip3d.rs +++ b/crates/re_types/src/components/line_strip3d.rs @@ -100,8 +100,6 @@ impl ::re_types_core::Loggable for LineStrip3D { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -109,14 +107,16 @@ impl ::re_types_core::Loggable for LineStrip3D { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data_inner_data: Vec<_> = data0_inner_data - .iter() - .map(|datum| datum.0.clone()) + .into_iter() + .map(|datum| datum.0) .flatten() .collect(); let data0_inner_data_inner_bitmap: Option = None; diff --git a/crates/re_types/src/components/media_type.rs b/crates/re_types/src/components/media_type.rs index cf710c0f6831..5c8aa98027da 100644 --- a/crates/re_types/src/components/media_type.rs +++ b/crates/re_types/src/components/media_type.rs @@ -104,11 +104,6 @@ impl ::re_types_core::Loggable for MediaType { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -116,6 +111,11 @@ impl ::re_types_core::Loggable for MediaType { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/components/name.rs b/crates/re_types/src/components/name.rs index cafa15ae4cb7..f50f37879b49 100644 --- a/crates/re_types/src/components/name.rs +++ b/crates/re_types/src/components/name.rs @@ -101,11 +101,6 @@ impl ::re_types_core::Loggable for Name { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -113,6 +108,11 @@ impl ::re_types_core::Loggable for Name { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/components/pinhole_projection.rs b/crates/re_types/src/components/pinhole_projection.rs index 2270653e3818..cf4768e7e36b 100644 --- a/crates/re_types/src/components/pinhole_projection.rs +++ b/crates/re_types/src/components/pinhole_projection.rs @@ -115,7 +115,7 @@ impl ::re_types_core::Loggable for PinholeProjection { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/position2d.rs b/crates/re_types/src/components/position2d.rs index 875fe4219902..348fdbb43fc2 100644 --- a/crates/re_types/src/components/position2d.rs +++ b/crates/re_types/src/components/position2d.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for Position2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/position3d.rs b/crates/re_types/src/components/position3d.rs index 25419e4b2314..689ea46865cf 100644 --- a/crates/re_types/src/components/position3d.rs +++ b/crates/re_types/src/components/position3d.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for Position3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/range1d.rs b/crates/re_types/src/components/range1d.rs index 125017d4ee42..2143b5aa8b3d 100644 --- a/crates/re_types/src/components/range1d.rs +++ b/crates/re_types/src/components/range1d.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for Range1D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/resolution.rs b/crates/re_types/src/components/resolution.rs index 616956a639e2..ba04c4164c81 100644 --- a/crates/re_types/src/components/resolution.rs +++ b/crates/re_types/src/components/resolution.rs @@ -107,7 +107,7 @@ impl ::re_types_core::Loggable for Resolution { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/texcoord2d.rs b/crates/re_types/src/components/texcoord2d.rs index 631f8809528d..d7bd6a0e7c54 100644 --- a/crates/re_types/src/components/texcoord2d.rs +++ b/crates/re_types/src/components/texcoord2d.rs @@ -121,7 +121,7 @@ impl ::re_types_core::Loggable for Texcoord2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/text.rs b/crates/re_types/src/components/text.rs index 0dd1763bcefe..199d596c82ac 100644 --- a/crates/re_types/src/components/text.rs +++ b/crates/re_types/src/components/text.rs @@ -101,11 +101,6 @@ impl ::re_types_core::Loggable for Text { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -113,6 +108,11 @@ impl ::re_types_core::Loggable for Text { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/components/text_log_level.rs b/crates/re_types/src/components/text_log_level.rs index 93a8dd0fef6b..bd860876aa90 100644 --- a/crates/re_types/src/components/text_log_level.rs +++ b/crates/re_types/src/components/text_log_level.rs @@ -109,11 +109,6 @@ impl ::re_types_core::Loggable for TextLogLevel { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = data0 - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -121,6 +116,11 @@ impl ::re_types_core::Loggable for TextLogLevel { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = data0 + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/components/triangle_indices.rs b/crates/re_types/src/components/triangle_indices.rs index 86dd3d09206b..f662dfad9d26 100644 --- a/crates/re_types/src/components/triangle_indices.rs +++ b/crates/re_types/src/components/triangle_indices.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for TriangleIndices { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/vector2d.rs b/crates/re_types/src/components/vector2d.rs index 0f3b5a5c98b0..c5e5f38a679a 100644 --- a/crates/re_types/src/components/vector2d.rs +++ b/crates/re_types/src/components/vector2d.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for Vector2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/vector3d.rs b/crates/re_types/src/components/vector3d.rs index 66bf1f79ab38..29fbb0b4733c 100644 --- a/crates/re_types/src/components/vector3d.rs +++ b/crates/re_types/src/components/vector3d.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for Vector3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/components/view_coordinates.rs b/crates/re_types/src/components/view_coordinates.rs index 3b2d0892847a..8b1a33eae2d4 100644 --- a/crates/re_types/src/components/view_coordinates.rs +++ b/crates/re_types/src/components/view_coordinates.rs @@ -116,9 +116,9 @@ impl ::re_types_core::Loggable for ViewCoordinates { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(3usize), ), diff --git a/crates/re_types/src/datatypes/annotation_info.rs b/crates/re_types/src/datatypes/annotation_info.rs index 57a478750060..b078f6c71f79 100644 --- a/crates/re_types/src/datatypes/annotation_info.rs +++ b/crates/re_types/src/datatypes/annotation_info.rs @@ -130,11 +130,6 @@ impl ::re_types_core::Loggable for AnnotationInfo { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = label - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( label.iter().map(|opt| { opt.as_ref().map(|datum| datum.0.len()).unwrap_or_default() @@ -142,6 +137,11 @@ impl ::re_types_core::Loggable for AnnotationInfo { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = label + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( diff --git a/crates/re_types/src/datatypes/class_description.rs b/crates/re_types/src/datatypes/class_description.rs index 026c75067144..31e19ea8ec6d 100644 --- a/crates/re_types/src/datatypes/class_description.rs +++ b/crates/re_types/src/datatypes/class_description.rs @@ -162,14 +162,6 @@ impl ::re_types_core::Loggable for ClassDescription { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let keypoint_annotations_inner_data: Vec<_> = keypoint_annotations - .iter() - .flatten() - .flatten() - .cloned() - .collect(); - let keypoint_annotations_inner_bitmap: Option = - None; let offsets = arrow2::offset::Offsets::::try_from_lengths( keypoint_annotations .iter() @@ -177,6 +169,13 @@ impl ::re_types_core::Loggable for ClassDescription { ) .unwrap() .into(); + let keypoint_annotations_inner_data: Vec<_> = keypoint_annotations + .into_iter() + .flatten() + .flatten() + .collect(); + let keypoint_annotations_inner_bitmap: Option = + None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -211,14 +210,6 @@ impl ::re_types_core::Loggable for ClassDescription { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let keypoint_connections_inner_data: Vec<_> = keypoint_connections - .iter() - .flatten() - .flatten() - .cloned() - .collect(); - let keypoint_connections_inner_bitmap: Option = - None; let offsets = arrow2::offset::Offsets::::try_from_lengths( keypoint_connections .iter() @@ -226,6 +217,13 @@ impl ::re_types_core::Loggable for ClassDescription { ) .unwrap() .into(); + let keypoint_connections_inner_data: Vec<_> = keypoint_connections + .into_iter() + .flatten() + .flatten() + .collect(); + let keypoint_connections_inner_bitmap: Option = + None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", diff --git a/crates/re_types/src/datatypes/mat3x3.rs b/crates/re_types/src/datatypes/mat3x3.rs index fe66a1926431..78ad00322445 100644 --- a/crates/re_types/src/datatypes/mat3x3.rs +++ b/crates/re_types/src/datatypes/mat3x3.rs @@ -109,9 +109,9 @@ impl ::re_types_core::Loggable for Mat3x3 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(9usize), ), diff --git a/crates/re_types/src/datatypes/mat4x4.rs b/crates/re_types/src/datatypes/mat4x4.rs index de2b4c1cdc80..33dc16275b31 100644 --- a/crates/re_types/src/datatypes/mat4x4.rs +++ b/crates/re_types/src/datatypes/mat4x4.rs @@ -110,9 +110,9 @@ impl ::re_types_core::Loggable for Mat4x4 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(16usize), ), diff --git a/crates/re_types/src/datatypes/quaternion.rs b/crates/re_types/src/datatypes/quaternion.rs index 15b45c6c0e2a..60a457f09cb3 100644 --- a/crates/re_types/src/datatypes/quaternion.rs +++ b/crates/re_types/src/datatypes/quaternion.rs @@ -100,9 +100,9 @@ impl ::re_types_core::Loggable for Quaternion { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(4usize), ), diff --git a/crates/re_types/src/datatypes/range1d.rs b/crates/re_types/src/datatypes/range1d.rs index a2a2648018d3..421464145c69 100644 --- a/crates/re_types/src/datatypes/range1d.rs +++ b/crates/re_types/src/datatypes/range1d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for Range1D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(2usize), ), diff --git a/crates/re_types/src/datatypes/range2d.rs b/crates/re_types/src/datatypes/range2d.rs index fe5b844300e1..f063f1169ab9 100644 --- a/crates/re_types/src/datatypes/range2d.rs +++ b/crates/re_types/src/datatypes/range2d.rs @@ -112,7 +112,7 @@ impl ::re_types_core::Loggable for Range2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let x_range_inner_data: Vec<_> = x_range - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); @@ -160,7 +160,7 @@ impl ::re_types_core::Loggable for Range2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let y_range_inner_data: Vec<_> = y_range - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/datatypes/rotation3d.rs b/crates/re_types/src/datatypes/rotation3d.rs index 459b2524caa3..8f051ae16d2c 100644 --- a/crates/re_types/src/datatypes/rotation3d.rs +++ b/crates/re_types/src/datatypes/rotation3d.rs @@ -121,8 +121,8 @@ impl ::re_types_core::Loggable for Rotation3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let quaternion_inner_data: Vec<_> = quaternion - .iter() - .map(|datum| datum.0.clone()) + .into_iter() + .map(|datum| datum.0) .flatten() .collect(); let quaternion_inner_bitmap: Option = None; diff --git a/crates/re_types/src/datatypes/rotation_axis_angle.rs b/crates/re_types/src/datatypes/rotation_axis_angle.rs index e7a8571c71c1..03a53170ee22 100644 --- a/crates/re_types/src/datatypes/rotation_axis_angle.rs +++ b/crates/re_types/src/datatypes/rotation_axis_angle.rs @@ -107,7 +107,7 @@ impl ::re_types_core::Loggable for RotationAxisAngle { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let axis_inner_data: Vec<_> = axis - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/datatypes/scale3d.rs b/crates/re_types/src/datatypes/scale3d.rs index b5e7c8fcda88..8412c949d53b 100644 --- a/crates/re_types/src/datatypes/scale3d.rs +++ b/crates/re_types/src/datatypes/scale3d.rs @@ -112,11 +112,8 @@ impl ::re_types_core::Loggable for Scale3D { let three_d_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let three_d_inner_data: Vec<_> = three_d - .iter() - .map(|datum| datum.0.clone()) - .flatten() - .collect(); + let three_d_inner_data: Vec<_> = + three_d.into_iter().map(|datum| datum.0).flatten().collect(); let three_d_inner_bitmap: Option = None; FixedSizeListArray::new( DataType::FixedSizeList( diff --git a/crates/re_types/src/datatypes/tensor_buffer.rs b/crates/re_types/src/datatypes/tensor_buffer.rs index aa3fca8fc9dd..eacac97cfb0d 100644 --- a/crates/re_types/src/datatypes/tensor_buffer.rs +++ b/crates/re_types/src/datatypes/tensor_buffer.rs @@ -318,6 +318,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let u8_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + u8.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let u8_inner_data: Buffer<_> = u8 .iter() .map(|b| b.as_slice()) @@ -325,11 +330,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let u8_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - u8.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -355,6 +355,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let u16_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + u16.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let u16_inner_data: Buffer<_> = u16 .iter() .map(|b| b.as_slice()) @@ -362,11 +367,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let u16_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - u16.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -392,6 +392,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let u32_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + u32.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let u32_inner_data: Buffer<_> = u32 .iter() .map(|b| b.as_slice()) @@ -399,11 +404,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let u32_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - u32.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -429,6 +429,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let u64_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + u64.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let u64_inner_data: Buffer<_> = u64 .iter() .map(|b| b.as_slice()) @@ -436,11 +441,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let u64_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - u64.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -466,6 +466,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let i8_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + i8.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let i8_inner_data: Buffer<_> = i8 .iter() .map(|b| b.as_slice()) @@ -473,11 +478,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let i8_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - i8.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -503,6 +503,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let i16_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + i16.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let i16_inner_data: Buffer<_> = i16 .iter() .map(|b| b.as_slice()) @@ -510,11 +515,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let i16_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - i16.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -540,6 +540,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let i32_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + i32.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let i32_inner_data: Buffer<_> = i32 .iter() .map(|b| b.as_slice()) @@ -547,11 +552,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let i32_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - i32.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -577,6 +577,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let i64_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + i64.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let i64_inner_data: Buffer<_> = i64 .iter() .map(|b| b.as_slice()) @@ -584,11 +589,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let i64_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - i64.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -614,6 +614,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let f16_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + f16.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let f16_inner_data: Buffer<_> = f16 .iter() .map(|b| b.as_slice()) @@ -621,11 +626,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let f16_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - f16.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -655,6 +655,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let f32_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + f32.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let f32_inner_data: Buffer<_> = f32 .iter() .map(|b| b.as_slice()) @@ -662,11 +667,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let f32_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - f32.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -696,6 +696,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let f64_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + f64.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let f64_inner_data: Buffer<_> = f64 .iter() .map(|b| b.as_slice()) @@ -703,11 +708,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let f64_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - f64.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -737,6 +737,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let jpeg_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + jpeg.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let jpeg_inner_data: Buffer<_> = jpeg .iter() .map(|b| b.as_slice()) @@ -744,11 +749,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let jpeg_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - jpeg.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -778,6 +778,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let nv12_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + nv12.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let nv12_inner_data: Buffer<_> = nv12 .iter() .map(|b| b.as_slice()) @@ -785,11 +790,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let nv12_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - nv12.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -819,6 +819,11 @@ impl ::re_types_core::Loggable for TensorBuffer { let yuy2_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + yuy2.iter().map(|datum| datum.num_instances()), + ) + .unwrap() + .into(); let yuy2_inner_data: Buffer<_> = yuy2 .iter() .map(|b| b.as_slice()) @@ -826,11 +831,6 @@ impl ::re_types_core::Loggable for TensorBuffer { .concat() .into(); let yuy2_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - yuy2.iter().map(|datum| datum.num_instances()), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", diff --git a/crates/re_types/src/datatypes/tensor_data.rs b/crates/re_types/src/datatypes/tensor_data.rs index 3aeb6f840328..0fb6be089d07 100644 --- a/crates/re_types/src/datatypes/tensor_data.rs +++ b/crates/re_types/src/datatypes/tensor_data.rs @@ -127,9 +127,6 @@ impl ::re_types_core::Loggable for TensorData { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let shape_inner_data: Vec<_> = - shape.iter().flatten().flatten().cloned().collect(); - let shape_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( shape .iter() @@ -137,6 +134,9 @@ impl ::re_types_core::Loggable for TensorData { ) .unwrap() .into(); + let shape_inner_data: Vec<_> = + shape.into_iter().flatten().flatten().collect(); + let shape_inner_bitmap: Option = None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", diff --git a/crates/re_types/src/datatypes/tensor_dimension.rs b/crates/re_types/src/datatypes/tensor_dimension.rs index 018f3d281cae..25b9dc4750bd 100644 --- a/crates/re_types/src/datatypes/tensor_dimension.rs +++ b/crates/re_types/src/datatypes/tensor_dimension.rs @@ -121,14 +121,14 @@ impl ::re_types_core::Loggable for TensorDimension { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - name.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths(name.iter().map( |opt| opt.as_ref().map(|datum| datum.len()).unwrap_or_default(), )) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + name.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( diff --git a/crates/re_types/src/datatypes/translation_and_mat3x3.rs b/crates/re_types/src/datatypes/translation_and_mat3x3.rs index 39161f47b725..17f96f0d9122 100644 --- a/crates/re_types/src/datatypes/translation_and_mat3x3.rs +++ b/crates/re_types/src/datatypes/translation_and_mat3x3.rs @@ -123,7 +123,7 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let translation_inner_data: Vec<_> = translation - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); @@ -172,7 +172,7 @@ impl ::re_types_core::Loggable for TranslationAndMat3x3 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let mat3x3_inner_data: Vec<_> = mat3x3 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs index 69f32ae11330..51127b5ff499 100644 --- a/crates/re_types/src/datatypes/translation_rotation_scale3d.rs +++ b/crates/re_types/src/datatypes/translation_rotation_scale3d.rs @@ -131,7 +131,7 @@ impl ::re_types_core::Loggable for TranslationRotationScale3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let translation_inner_data: Vec<_> = translation - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.0).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types/src/datatypes/uuid.rs b/crates/re_types/src/datatypes/uuid.rs index 28e0d6c386de..a0700a859c74 100644 --- a/crates/re_types/src/datatypes/uuid.rs +++ b/crates/re_types/src/datatypes/uuid.rs @@ -101,9 +101,9 @@ impl ::re_types_core::Loggable for Uuid { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let bytes_inner_data: Vec<_> = bytes - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(16usize), ), diff --git a/crates/re_types/src/datatypes/uvec2d.rs b/crates/re_types/src/datatypes/uvec2d.rs index 2e2e2dc758a9..aa8e1f14d157 100644 --- a/crates/re_types/src/datatypes/uvec2d.rs +++ b/crates/re_types/src/datatypes/uvec2d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for UVec2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(2usize), ), diff --git a/crates/re_types/src/datatypes/uvec3d.rs b/crates/re_types/src/datatypes/uvec3d.rs index d46edc100ec9..10b66c53c3e1 100644 --- a/crates/re_types/src/datatypes/uvec3d.rs +++ b/crates/re_types/src/datatypes/uvec3d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for UVec3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(3usize), ), diff --git a/crates/re_types/src/datatypes/uvec4d.rs b/crates/re_types/src/datatypes/uvec4d.rs index 53513871c9e2..e8ea68b1fe52 100644 --- a/crates/re_types/src/datatypes/uvec4d.rs +++ b/crates/re_types/src/datatypes/uvec4d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for UVec4D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(4usize), ), diff --git a/crates/re_types/src/datatypes/vec2d.rs b/crates/re_types/src/datatypes/vec2d.rs index e72ee24860c9..654637f430aa 100644 --- a/crates/re_types/src/datatypes/vec2d.rs +++ b/crates/re_types/src/datatypes/vec2d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for Vec2D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(2usize), ), diff --git a/crates/re_types/src/datatypes/vec3d.rs b/crates/re_types/src/datatypes/vec3d.rs index 4695b05badfa..e06e46cca0d8 100644 --- a/crates/re_types/src/datatypes/vec3d.rs +++ b/crates/re_types/src/datatypes/vec3d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for Vec3D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(3usize), ), diff --git a/crates/re_types/src/datatypes/vec4d.rs b/crates/re_types/src/datatypes/vec4d.rs index ee7535c6f526..9d4ae649f169 100644 --- a/crates/re_types/src/datatypes/vec4d.rs +++ b/crates/re_types/src/datatypes/vec4d.rs @@ -98,9 +98,9 @@ impl ::re_types_core::Loggable for Vec4D { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(4usize), ), diff --git a/crates/re_types/src/testing/components/affix_fuzzer10.rs b/crates/re_types/src/testing/components/affix_fuzzer10.rs index 1627b4677ec3..531b99ae20fe 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer10.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer10.rs @@ -91,8 +91,6 @@ impl ::re_types_core::Loggable for AffixFuzzer10 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - data0.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -100,6 +98,8 @@ impl ::re_types_core::Loggable for AffixFuzzer10 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/testing/components/affix_fuzzer11.rs b/crates/re_types/src/testing/components/affix_fuzzer11.rs index 4f2bf5d030d9..c762e159b086 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer11.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer11.rs @@ -96,6 +96,13 @@ impl ::re_types_core::Loggable for AffixFuzzer11 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + data0 + .iter() + .map(|opt| opt.as_ref().map_or(0, |datum| datum.num_instances())), + ) + .unwrap() + .into(); let data0_inner_data: Buffer<_> = data0 .iter() .flatten() @@ -104,13 +111,6 @@ impl ::re_types_core::Loggable for AffixFuzzer11 { .concat() .into(); let data0_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - data0 - .iter() - .map(|opt| opt.as_ref().map_or(0, |datum| datum.num_instances())), - ) - .unwrap() - .into(); ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/testing/components/affix_fuzzer12.rs b/crates/re_types/src/testing/components/affix_fuzzer12.rs index 036d69e1afb4..ef40dfcd38e4 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer12.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer12.rs @@ -96,8 +96,6 @@ impl ::re_types_core::Loggable for AffixFuzzer12 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -105,17 +103,19 @@ impl ::re_types_core::Loggable for AffixFuzzer12 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, { - let inner_data: arrow2::buffer::Buffer = - data0_inner_data.iter().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0_inner_data.iter().map(|datum| datum.len()), ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0_inner_data.into_iter().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/testing/components/affix_fuzzer13.rs b/crates/re_types/src/testing/components/affix_fuzzer13.rs index b90eccab103f..c98fda74caa5 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer13.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer13.rs @@ -96,8 +96,6 @@ impl ::re_types_core::Loggable for AffixFuzzer13 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -105,17 +103,19 @@ impl ::re_types_core::Loggable for AffixFuzzer13 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, { - let inner_data: arrow2::buffer::Buffer = - data0_inner_data.iter().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0_inner_data.iter().map(|datum| datum.len()), ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0_inner_data.into_iter().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/testing/components/affix_fuzzer16.rs b/crates/re_types/src/testing/components/affix_fuzzer16.rs index 46c98d5935f8..b23a20aa57eb 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer16.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer16.rs @@ -90,8 +90,6 @@ impl ::re_types_core::Loggable for AffixFuzzer16 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -99,6 +97,8 @@ impl ::re_types_core::Loggable for AffixFuzzer16 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/testing/components/affix_fuzzer17.rs b/crates/re_types/src/testing/components/affix_fuzzer17.rs index 3f0a8e510970..a3d59365b42d 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer17.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer17.rs @@ -90,8 +90,6 @@ impl ::re_types_core::Loggable for AffixFuzzer17 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -99,6 +97,8 @@ impl ::re_types_core::Loggable for AffixFuzzer17 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/testing/components/affix_fuzzer18.rs b/crates/re_types/src/testing/components/affix_fuzzer18.rs index c15a7cd76b07..5de1a6b3bb72 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer18.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer18.rs @@ -90,8 +90,6 @@ impl ::re_types_core::Loggable for AffixFuzzer18 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -99,6 +97,8 @@ impl ::re_types_core::Loggable for AffixFuzzer18 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/testing/components/affix_fuzzer7.rs b/crates/re_types/src/testing/components/affix_fuzzer7.rs index 0a12ecfc7bfa..8945acbfde04 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer7.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer7.rs @@ -90,8 +90,6 @@ impl ::re_types_core::Loggable for AffixFuzzer7 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -99,6 +97,8 @@ impl ::re_types_core::Loggable for AffixFuzzer7 { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, diff --git a/crates/re_types/src/testing/components/affix_fuzzer9.rs b/crates/re_types/src/testing/components/affix_fuzzer9.rs index ffa4f7f06319..057c0f609f4e 100644 --- a/crates/re_types/src/testing/components/affix_fuzzer9.rs +++ b/crates/re_types/src/testing/components/affix_fuzzer9.rs @@ -91,8 +91,6 @@ impl ::re_types_core::Loggable for AffixFuzzer9 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - data0.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -100,6 +98,8 @@ impl ::re_types_core::Loggable for AffixFuzzer9 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs index 2ba0f8dbeaeb..e8839c75b81c 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer1.rs @@ -182,11 +182,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = single_string_required - .iter() - .flatten() - .flat_map(|s| s.0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( single_string_required.iter().map(|opt| { opt.as_ref().map(|datum| datum.len()).unwrap_or_default() @@ -194,7 +189,11 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); - + let inner_data: arrow2::buffer::Buffer = single_string_required + .into_iter() + .flatten() + .flat_map(|s| s.0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( @@ -223,11 +222,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = single_string_optional - .iter() - .flatten() - .flat_map(|s| s.0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( single_string_optional.iter().map(|opt| { opt.as_ref().map(|datum| datum.len()).unwrap_or_default() @@ -235,7 +229,11 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); - + let inner_data: arrow2::buffer::Buffer = single_string_optional + .into_iter() + .flatten() + .flat_map(|s| s.0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( @@ -265,6 +263,13 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + many_floats_optional.iter().map(|opt| { + opt.as_ref().map_or(0, |datum| datum.num_instances()) + }), + ) + .unwrap() + .into(); let many_floats_optional_inner_data: Buffer<_> = many_floats_optional .iter() .flatten() @@ -274,13 +279,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { .into(); let many_floats_optional_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - many_floats_optional.iter().map(|opt| { - opt.as_ref().map_or(0, |datum| datum.num_instances()) - }), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -315,14 +313,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let many_strings_required_inner_data: Vec<_> = many_strings_required - .iter() - .flatten() - .flatten() - .cloned() - .collect(); - let many_strings_required_inner_bitmap: Option = - None; let offsets = arrow2::offset::Offsets::::try_from_lengths( many_strings_required .iter() @@ -330,6 +320,13 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .unwrap() .into(); + let many_strings_required_inner_data: Vec<_> = many_strings_required + .into_iter() + .flatten() + .flatten() + .collect(); + let many_strings_required_inner_bitmap: Option = + None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -338,11 +335,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ))), offsets, { - let inner_data: arrow2::buffer::Buffer = - many_strings_required_inner_data - .iter() - .flat_map(|s| s.0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( many_strings_required_inner_data .iter() @@ -350,6 +342,11 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + many_strings_required_inner_data + .into_iter() + .flat_map(|s| s.0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( @@ -383,14 +380,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let many_strings_optional_inner_data: Vec<_> = many_strings_optional - .iter() - .flatten() - .flatten() - .cloned() - .collect(); - let many_strings_optional_inner_bitmap: Option = - None; let offsets = arrow2::offset::Offsets::::try_from_lengths( many_strings_optional .iter() @@ -398,6 +387,13 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .unwrap() .into(); + let many_strings_optional_inner_data: Vec<_> = many_strings_optional + .into_iter() + .flatten() + .flatten() + .collect(); + let many_strings_optional_inner_bitmap: Option = + None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -406,11 +402,6 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ))), offsets, { - let inner_data: arrow2::buffer::Buffer = - many_strings_optional_inner_data - .iter() - .flat_map(|s| s.0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( many_strings_optional_inner_data .iter() @@ -418,6 +409,11 @@ impl ::re_types_core::Loggable for AffixFuzzer1 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + many_strings_optional_inner_data + .into_iter() + .flat_map(|s| s.0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs index c3675eee3f3f..cadd48ed4c37 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer20.rs @@ -127,11 +127,6 @@ impl ::re_types_core::Loggable for AffixFuzzer20 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = s - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( s.iter().map(|opt| { opt.as_ref().map(|datum| datum.0.len()).unwrap_or_default() @@ -139,6 +134,11 @@ impl ::re_types_core::Loggable for AffixFuzzer20 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = s + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked( diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs index 9e4f59d5b00e..d4b30a76a763 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer21.rs @@ -129,6 +129,13 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; + let offsets = arrow2::offset::Offsets::::try_from_lengths( + many_halves.iter().map(|opt| { + opt.as_ref().map_or(0, |datum| datum.num_instances()) + }), + ) + .unwrap() + .into(); let many_halves_inner_data: Buffer<_> = many_halves .iter() .flatten() @@ -137,13 +144,6 @@ impl ::re_types_core::Loggable for AffixFuzzer21 { .concat() .into(); let many_halves_inner_bitmap: Option = None; - let offsets = arrow2::offset::Offsets::::try_from_lengths( - many_halves.iter().map(|opt| { - opt.as_ref().map_or(0, |datum| datum.num_instances()) - }), - ) - .unwrap() - .into(); ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer22.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer22.rs index 0b2d16fc05ca..6cce8be8da55 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer22.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer22.rs @@ -116,9 +116,9 @@ impl ::re_types_core::Loggable for AffixFuzzer22 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let fixed_sized_native_inner_data: Vec<_> = fixed_sized_native - .iter() + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(4usize), ), diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs index 3bac7336052a..3ed62687638e 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer3.rs @@ -149,14 +149,14 @@ impl ::re_types_core::Loggable for AffixFuzzer3 { let craziness_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let craziness_inner_data: Vec<_> = - craziness.iter().flatten().cloned().collect(); - let craziness_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( craziness.iter().map(|datum| datum.len()), ) .unwrap() .into(); + let craziness_inner_data: Vec<_> = + craziness.into_iter().flatten().collect(); + let craziness_inner_bitmap: Option = None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", @@ -187,7 +187,7 @@ impl ::re_types_core::Loggable for AffixFuzzer3 { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let fixed_size_shenanigans_inner_data: Vec<_> = - fixed_size_shenanigans.iter().flatten().cloned().collect(); + fixed_size_shenanigans.into_iter().flatten().collect(); let fixed_size_shenanigans_inner_bitmap: Option = None; FixedSizeListArray::new( diff --git a/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs b/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs index d6fac9ef0b43..18a4330e5c38 100644 --- a/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs +++ b/crates/re_types/src/testing/datatypes/affix_fuzzer4.rs @@ -137,14 +137,14 @@ impl ::re_types_core::Loggable for AffixFuzzer4 { let many_required_bitmap: Option = None; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let many_required_inner_data: Vec<_> = - many_required.iter().flatten().cloned().collect(); - let many_required_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( many_required.iter().map(|datum| datum.len()), ) .unwrap() .into(); + let many_required_inner_data: Vec<_> = + many_required.into_iter().flatten().collect(); + let many_required_inner_bitmap: Option = None; ListArray::new( DataType::List(std::sync::Arc::new(Field::new( "item", diff --git a/crates/re_types/src/testing/datatypes/string_component.rs b/crates/re_types/src/testing/datatypes/string_component.rs index 58ad30fbeb86..0c94aee8ea2e 100644 --- a/crates/re_types/src/testing/datatypes/string_component.rs +++ b/crates/re_types/src/testing/datatypes/string_component.rs @@ -92,8 +92,6 @@ impl ::re_types_core::Loggable for StringComponent { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - data0.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -101,6 +99,8 @@ impl ::re_types_core::Loggable for StringComponent { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types_blueprint/src/blueprint/components/included_space_view.rs b/crates/re_types_blueprint/src/blueprint/components/included_space_view.rs index 88d6530bdf01..ab1e850899b3 100644 --- a/crates/re_types_blueprint/src/blueprint/components/included_space_view.rs +++ b/crates/re_types_blueprint/src/blueprint/components/included_space_view.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for IncludedSpaceView { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.bytes).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types_blueprint/src/blueprint/components/root_container.rs b/crates/re_types_blueprint/src/blueprint/components/root_container.rs index 37a6b144b7a5..4533206bcfd4 100644 --- a/crates/re_types_blueprint/src/blueprint/components/root_container.rs +++ b/crates/re_types_blueprint/src/blueprint/components/root_container.rs @@ -109,7 +109,7 @@ impl ::re_types_core::Loggable for RootContainer { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.bytes).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types_blueprint/src/blueprint/components/space_view_maximized.rs b/crates/re_types_blueprint/src/blueprint/components/space_view_maximized.rs index a7f510b65c8f..31471e25928f 100644 --- a/crates/re_types_blueprint/src/blueprint/components/space_view_maximized.rs +++ b/crates/re_types_blueprint/src/blueprint/components/space_view_maximized.rs @@ -106,7 +106,7 @@ impl ::re_types_core::Loggable for SpaceViewMaximized { { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; let data0_inner_data: Vec<_> = data0 - .iter() + .into_iter() .map(|datum| datum.map(|datum| datum.bytes).unwrap_or_default()) .flatten() .collect(); diff --git a/crates/re_types_builder/src/codegen/rust/serializer.rs b/crates/re_types_builder/src/codegen/rust/serializer.rs index 230580d2b5ec..2d2a8ae2ebca 100644 --- a/crates/re_types_builder/src/codegen/rust/serializer.rs +++ b/crates/re_types_builder/src/codegen/rust/serializer.rs @@ -287,12 +287,12 @@ pub fn quote_arrow_serializer( quote! {{ let #data_dst: Vec<_> = data - .iter() - .filter_map(|datum| match datum.as_deref() { - Some(#quoted_obj_name::#quoted_obj_field_name(v)) => Some(v.clone()), - _ => None, - }) - .collect(); + .iter() + .filter_map(|datum| match datum.as_deref() { + Some(#quoted_obj_name::#quoted_obj_field_name(v)) => Some(v.clone()), + _ => None, + }) + .collect(); let #bitmap_dst: Option = None; #quoted_serializer @@ -495,8 +495,6 @@ fn quote_arrow_field_serializer( quote! { BooleanArray::new( #quoted_datatype, - // NOTE: We need values for all slots, regardless of what the bitmap says, - // hence `unwrap_or_default`. #data_src.into_iter() #quoted_transparent_mapping .collect(), #bitmap_src, ).boxed() @@ -551,8 +549,7 @@ fn quote_arrow_field_serializer( ( quote! { .flat_map(|datum| { - // NOTE: `Buffer::clone`, which is just a ref-count bump - datum.#quoted_member_accessor.0.clone() + datum.#quoted_member_accessor.0 }) }, quote! { @@ -564,8 +561,7 @@ fn quote_arrow_field_serializer( } else { ( quote! { - // NOTE: `Buffer::clone`, which is just a ref-count bump - .flat_map(|s| s.0.clone()) + .flat_map(|s| s.0) }, quote! { .map(|datum| datum.len()) @@ -575,27 +571,27 @@ fn quote_arrow_field_serializer( let inner_data_and_offsets = if elements_are_nullable { 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() #quoted_transparent_mapping.collect(); - let offsets = arrow2::offset::Offsets::::try_from_lengths( #data_src.iter().map(|opt| opt.as_ref() #quoted_transparent_length .unwrap_or_default()) ) .map_err(|err| std::sync::Arc::new(err))? .into(); + + // 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.into_iter().flatten() #quoted_transparent_mapping.collect(); } } else { quote! { - let inner_data: arrow2::buffer::Buffer = - #data_src.iter() #quoted_transparent_mapping.collect(); - let offsets = arrow2::offset::Offsets::::try_from_lengths( #data_src.iter() #quoted_transparent_length ) .map_err(|err| std::sync::Arc::new(err))? .into(); + + let inner_data: arrow2::buffer::Buffer = + #data_src.into_iter() #quoted_transparent_mapping.collect(); } }; @@ -667,6 +663,8 @@ fn quote_arrow_field_serializer( if elements_are_nullable { quote! { + #data_src + .into_iter() .map(|datum| { datum .map(|datum| { @@ -679,8 +677,10 @@ fn quote_arrow_field_serializer( } } else { quote! { + #data_src + .into_iter() .map(|datum| { - datum.#quoted_member_accessor.clone() + datum.#quoted_member_accessor }) // NOTE: Flattening yet since we have to deconstruct the inner list. .flatten() @@ -697,6 +697,8 @@ fn quote_arrow_field_serializer( InnerRepr::ArrowBuffer => { if serde_type.is_some() { quote! { + #data_src + .into_iter() .map(|opt| { use ::re_types_core::SerializationError; // otherwise rustfmt breaks opt.as_ref().map(|b| { @@ -710,12 +712,15 @@ fn quote_arrow_field_serializer( .collect::>>()? } } else { + // TODO(emilk): this can probably be optimized quote! { + #data_src + .iter() #flatten_if_needed .map(|b| b.as_slice()) .collect::>() .concat() - .into(); + .into() } } } @@ -723,8 +728,10 @@ fn quote_arrow_field_serializer( if let DataType::FixedSizeList(_, count) = datatype.to_logical_type() { if elements_are_nullable { quote! { + #data_src + .into_iter() .flat_map(|v| match v { - Some(v) => itertools::Either::Left(v.iter().cloned()), + Some(v) => itertools::Either::Left(v.into_iter()), None => itertools::Either::Right( std::iter::repeat(Default::default()).take(#count), ), @@ -732,15 +739,18 @@ fn quote_arrow_field_serializer( } } else { quote! { - .flatten().cloned() + #data_src + .into_iter() + .flatten() } } } else { quote! { + #data_src + .into_iter() #flatten_if_needed // NOTE: Flattening yet again since we have to deconstruct the inner list. .flatten() - .cloned() } } } @@ -752,7 +762,7 @@ fn quote_arrow_field_serializer( InnerRepr::NativeIterable => quote!(len()), }; - let quoted_create = if let DataType::List(_) = datatype { + let quoted_declare_offsets = if let DataType::List(_) = datatype { if serde_type.is_some() { quote! {} } else { @@ -766,7 +776,17 @@ fn quote_arrow_field_serializer( let offsets = arrow2::offset::Offsets::::try_from_lengths( #data_src.iter(). #map_to_length ).unwrap().into(); + } + } + } else { + quote! {} + }; + let quoted_create = if let DataType::List(_) = datatype { + if serde_type.is_some() { + quote! {} + } else { + quote! { ListArray::new( #quoted_datatype, offsets, @@ -823,9 +843,7 @@ fn quote_arrow_field_serializer( quote! {{ use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let buffers: Vec>> = #data_src - .iter() - #quoted_transparent_mapping; + let buffers: Vec>> = #quoted_transparent_mapping; let offsets = arrow2::offset::Offsets::::try_from_lengths( buffers.iter().map(|opt| opt.as_ref().map_or(0, |buf| buf.len())) @@ -846,9 +864,9 @@ fn quote_arrow_field_serializer( quote! {{ use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let #quoted_inner_data: Buffer<_> = #data_src - .iter() - #quoted_transparent_mapping + #quoted_declare_offsets + + let #quoted_inner_data: Buffer<_> = #quoted_transparent_mapping; #quoted_inner_bitmap @@ -861,8 +879,9 @@ fn quote_arrow_field_serializer( quote! {{ use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let #quoted_inner_data: Vec<_> = #data_src - .iter() + #quoted_declare_offsets + + let #quoted_inner_data: Vec<_> = #quoted_transparent_mapping .collect(); diff --git a/crates/re_types_core/src/arrow_buffer.rs b/crates/re_types_core/src/arrow_buffer.rs index 933ffa469a75..73463d271fde 100644 --- a/crates/re_types_core/src/arrow_buffer.rs +++ b/crates/re_types_core/src/arrow_buffer.rs @@ -49,6 +49,11 @@ impl ArrowBuffer { pub fn as_slice(&self) -> &[T] { self.0.as_slice() } + + #[inline] + pub fn into_inner(self) -> Buffer { + self.0 + } } impl Eq for ArrowBuffer {} diff --git a/crates/re_types_core/src/components/visualizer_overrides.rs b/crates/re_types_core/src/components/visualizer_overrides.rs index ab9163d61a44..064856dc1c8c 100644 --- a/crates/re_types_core/src/components/visualizer_overrides.rs +++ b/crates/re_types_core/src/components/visualizer_overrides.rs @@ -98,8 +98,6 @@ impl crate::Loggable for VisualizerOverrides { }; { use arrow2::{buffer::Buffer, offset::OffsetsBuffer}; - let data0_inner_data: Vec<_> = data0.iter().flatten().flatten().cloned().collect(); - let data0_inner_bitmap: Option = None; let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -107,17 +105,19 @@ impl crate::Loggable for VisualizerOverrides { ) .unwrap() .into(); + let data0_inner_data: Vec<_> = data0.into_iter().flatten().flatten().collect(); + let data0_inner_bitmap: Option = None; ListArray::new( Self::arrow_datatype(), offsets, { - let inner_data: arrow2::buffer::Buffer = - data0_inner_data.iter().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0_inner_data.iter().map(|datum| datum.len()), ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0_inner_data.into_iter().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types_core/src/datatypes/entity_path.rs b/crates/re_types_core/src/datatypes/entity_path.rs index 86743a327cca..a42fe2236107 100644 --- a/crates/re_types_core/src/datatypes/entity_path.rs +++ b/crates/re_types_core/src/datatypes/entity_path.rs @@ -93,8 +93,6 @@ impl crate::Loggable for EntityPath { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - data0.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -102,6 +100,8 @@ impl crate::Loggable for EntityPath { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types_core/src/datatypes/utf8.rs b/crates/re_types_core/src/datatypes/utf8.rs index c6e8236fc0fe..c87dd877a47b 100644 --- a/crates/re_types_core/src/datatypes/utf8.rs +++ b/crates/re_types_core/src/datatypes/utf8.rs @@ -93,8 +93,6 @@ impl crate::Loggable for Utf8 { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = - data0.iter().flatten().flat_map(|s| s.0.clone()).collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( data0 .iter() @@ -102,6 +100,8 @@ impl crate::Loggable for Utf8 { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = + data0.into_iter().flatten().flat_map(|s| s.0).collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { diff --git a/crates/re_types_core/src/datatypes/visible_time_range.rs b/crates/re_types_core/src/datatypes/visible_time_range.rs index c25d058d95be..67f6877e2a1d 100644 --- a/crates/re_types_core/src/datatypes/visible_time_range.rs +++ b/crates/re_types_core/src/datatypes/visible_time_range.rs @@ -109,11 +109,6 @@ impl crate::Loggable for VisibleTimeRange { any_nones.then(|| somes.into()) }; { - let inner_data: arrow2::buffer::Buffer = timeline - .iter() - .flatten() - .flat_map(|datum| datum.0 .0.clone()) - .collect(); let offsets = arrow2::offset::Offsets::::try_from_lengths( timeline.iter().map(|opt| { opt.as_ref().map(|datum| datum.0.len()).unwrap_or_default() @@ -121,6 +116,11 @@ impl crate::Loggable for VisibleTimeRange { ) .map_err(|err| std::sync::Arc::new(err))? .into(); + let inner_data: arrow2::buffer::Buffer = timeline + .into_iter() + .flatten() + .flat_map(|datum| datum.0 .0) + .collect(); #[allow(unsafe_code, clippy::undocumented_unsafe_blocks)] unsafe { Utf8Array::::new_unchecked(