Skip to content

Commit

Permalink
Generate comments explaining sparse vs dense unions
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed May 9, 2024
1 parent 7177dca commit 5ddf875
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 1 deletion.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/blueprint/components/corner2d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/components/marker_shape.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/datatypes/angle.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/datatypes/rotation3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/datatypes/scale3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/datatypes/tensor_buffer.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/datatypes/transform3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/testing/components/enum_test.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/testing/datatypes/affix_fuzzer3.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/re_types/src/testing/datatypes/affix_fuzzer4.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion crates/re_types_builder/src/codegen/rust/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{ArrowRegistry, Object, ObjectField, Objects};

use super::{
arrow::{is_backed_by_arrow_buffer, quote_fqname_as_type_path},
util::is_tuple_struct_from_obj,
util::{is_tuple_struct_from_obj, quote_comment},
};

// ---
Expand Down Expand Up @@ -211,7 +211,11 @@ pub fn quote_arrow_serializer(

let num_variants = obj.fields.len();

let comment = quote_comment("Sparse Arrow union");

quote! {{
#comment

#quoted_data_collect

let num_variants = #num_variants;
Expand Down Expand Up @@ -380,7 +384,11 @@ pub fn quote_arrow_serializer(
}}
};

let comment = quote_comment("Dense Arrow union");

quote! {{
#comment

#quoted_data_collect

let types = #quoted_types;
Expand Down Expand Up @@ -609,6 +617,8 @@ fn quote_arrow_field_serializer(

// Safety: we're building this from actual native strings, so no need to do the
// whole utf8 validation _again_.
// It would be nice to use quote_comment here and put this safety notice in the generated code,
// but that seems to push us over some complexity limit causing rustfmt to fail.
#[allow(unsafe_code, clippy::undocumented_unsafe_blocks)]
unsafe { Utf8Array::<i32>::new_unchecked(#quoted_datatype, offsets, inner_data, #bitmap_src) }.boxed()
}}
Expand Down
1 change: 1 addition & 0 deletions crates/re_types_core/src/datatypes/time_range_boundary.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ddf875

Please sign in to comment.