Skip to content

Commit

Permalink
make Archetype::{from_arrow, to_arrow} and friends tag compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 9, 2025
1 parent f8db46c commit 455f098
Show file tree
Hide file tree
Showing 68 changed files with 1,316 additions and 1,462 deletions.
19 changes: 7 additions & 12 deletions crates/build/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,8 +1216,8 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
let all_deserializers = {
obj.fields.iter().map(|obj_field| {
let obj_field_fqname = obj_field.fqname.as_str();
let field_typ_fqname_str = obj_field.typ.fqname().unwrap();
let field_name = format_ident!("{}", obj_field.name);
let descr_fn_name = format_ident!("descriptor_{field_name}");

let is_plural = obj_field.typ.is_plural();
let is_nullable = obj_field.is_nullable;
Expand Down Expand Up @@ -1256,7 +1256,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
};

quote! {
if let Some(array) = arrays_by_name.get(#field_typ_fqname_str) {
if let Some(array) = arrays_by_descr.get(&Self::#descr_fn_name()) {
<#component>::from_arrow_opt(&**array)
.with_context(#obj_field_fqname)?
#quoted_collection
Expand All @@ -1266,7 +1266,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
}
} else if is_nullable {
quote! {
if let Some(array) = arrays_by_name.get(#field_typ_fqname_str) {
if let Some(array) = arrays_by_descr.get(&Self::#descr_fn_name()) {
Some({
<#component>::from_arrow_opt(&**array)
.with_context(#obj_field_fqname)?
Expand All @@ -1278,8 +1278,8 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
}
} else {
quote! {{
let array = arrays_by_name
.get(#field_typ_fqname_str)
let array = arrays_by_descr
.get(&Self::#descr_fn_name())
.ok_or_else(DeserializationError::missing_data)
.with_context(#obj_field_fqname)?;

Expand Down Expand Up @@ -1359,20 +1359,15 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
#[inline]
fn from_arrow_components(
arrow_data: impl IntoIterator<Item = (
ComponentName,
ComponentDescriptor,
arrow::array::ArrayRef,
)>,
) -> DeserializationResult<Self> {
re_tracing::profile_function!();

use ::re_types_core::{Loggable as _, ResultExt as _};

// NOTE: Even though ComponentName is an InternedString, we must
// convert to &str here because the .get("component.name") accessors
// will fail otherwise.
let arrays_by_name: ::std::collections::HashMap<_, _> = arrow_data
.into_iter()
.map(|(name, array)| (name.full_name(), array)).collect();
let arrays_by_descr: ::nohash_hasher::IntMap<_, _> = arrow_data.into_iter().collect();

#(#all_deserializers;)*

Expand Down
11 changes: 4 additions & 7 deletions crates/store/re_types/src/archetypes/annotation_context.rs

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

26 changes: 12 additions & 14 deletions crates/store/re_types/src/archetypes/arrows2d.rs

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

24 changes: 11 additions & 13 deletions crates/store/re_types/src/archetypes/arrows3d.rs

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

33 changes: 15 additions & 18 deletions crates/store/re_types/src/archetypes/asset3d.rs

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

13 changes: 5 additions & 8 deletions crates/store/re_types/src/archetypes/asset_video.rs

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

13 changes: 5 additions & 8 deletions crates/store/re_types/src/archetypes/bar_chart.rs

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

Loading

0 comments on commit 455f098

Please sign in to comment.