Skip to content

Commit

Permalink
no more rerun.archetypes.Scalar hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 27, 2025
1 parent 05d6ec2 commit 436cd04
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
18 changes: 4 additions & 14 deletions crates/build/re_types_builder/src/codegen/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2643,19 +2643,6 @@ fn quote_columnar_methods(reporter: &Reporter, obj: &Object, objects: &Objects)
};
let doc_block = indent::indent_by(12, quote_doc_lines(doc_string_lines));

// NOTE(#8768): Scalar indicators are extremely wasteful, and not actually used for anything.
let has_indicator = obj.fqname.as_str() != "rerun.archetypes.Scalar";
let pack_and_return = if has_indicator {
indent::indent_by(12, unindent("\
indicator_batch = DescribedComponentBatch(cls.indicator(), cls.indicator().component_descriptor())
indicator_column = indicator_batch.partition(np.zeros(len(lengths)))
return ComponentColumnList([indicator_column] + columns)
"))
} else {
"return ComponentColumnList(columns)".to_owned()
};

// NOTE: Calling `update_fields` is not an option: we need to be able to pass
// plural data, even to singular fields (mono-components).
unindent(&format!(
Expand All @@ -2680,7 +2667,10 @@ fn quote_columnar_methods(reporter: &Reporter, obj: &Object, objects: &Objects)
lengths = np.ones(len(batches[0]._batch.as_arrow_array()))
columns = [batch.partition(lengths) for batch in batches]
{pack_and_return}
indicator_batch = DescribedComponentBatch(cls.indicator(), cls.indicator().component_descriptor())
indicator_column = indicator_batch.partition(np.zeros(len(lengths)))
return ComponentColumnList([indicator_column] + columns)
"#
))
}
Expand Down
13 changes: 2 additions & 11 deletions crates/build/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,13 +1638,9 @@ fn quote_builder_from_obj(reporter: &Reporter, objects: &Objects, obj: &Object)
");
let columns_unary_doc = quote_doc_lines(&columns_unary_doc.lines().map(|l| l.to_owned()).collect_vec());

let has_indicator = obj.fqname.as_str() != "rerun.archetypes.Scalar";
let num_fields = required.iter().chain(optional.iter()).count();

let fields = required.iter().chain(optional.iter()).map(|field| {
let field_name = format_ident!("{}", field.name);
let clone = if num_fields == 1 && !has_indicator { quote!(.into_iter()) } else { quote!(.clone()) };
quote!(self.#field_name.map(|#field_name| #field_name.partitioned(_lengths #clone)).transpose()?)
quote!(self.#field_name.map(|#field_name| #field_name.partitioned(_lengths.clone())).transpose()?)
});

let field_lengths = required.iter().chain(optional.iter()).map(|field| {
Expand All @@ -1656,12 +1652,7 @@ fn quote_builder_from_obj(reporter: &Reporter, objects: &Objects, obj: &Object)
quote!(let #len_field_name = self.#field_name.as_ref().map(|b| b.array.len()))
});

let indicator_column = if !has_indicator {
// NOTE(#8768): Scalar indicators are extremely wasteful, and not actually used for anything.
quote!(None)
} else {
quote!(::re_types_core::indicator_column::<Self>(_lengths.into_iter().count())?)
};
let indicator_column = quote!(::re_types_core::indicator_column::<Self>(_lengths.into_iter().count())?);

quote! {
#columns_doc
Expand Down
5 changes: 3 additions & 2 deletions crates/store/re_types/src/archetypes/scalar.rs

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

5 changes: 4 additions & 1 deletion rerun_py/rerun_sdk/rerun/archetypes/scalar.py

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

0 comments on commit 436cd04

Please sign in to comment.