Skip to content

Commit

Permalink
Make tagged columnar updates work with mono-components too (#8769)
Browse files Browse the repository at this point in the history
* Generate plural methods even for mono-components, so they can be used
with `send_columns`.
* Update `scalar_send_columns` snippet to use new columnar APIs.

```rust
const STEPS: i64 = 64;

let times = TimeColumn::new_sequence("step", 0..STEPS);
let scalars = (0..STEPS).map(|step| (step as f64 / 10.0).sin());

rec.send_columns_v2(
    "scalars",
    [times],
    rerun::Scalar::update_fields()
        .with_many_scalar(scalars)
        .columns(std::iter::repeat(1).take(STEPS as _))?
        .filter(|column| !column.descriptor.component_name.contains("Indicator")),
)?;
```

* Follow-up to #8753
  • Loading branch information
teh-cmc authored Jan 22, 2025
1 parent 4c46f98 commit 85ba0dc
Show file tree
Hide file tree
Showing 27 changed files with 759 additions and 15 deletions.
22 changes: 22 additions & 0 deletions crates/build/re_types_builder/src/codegen/rust/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1876,13 +1876,35 @@ fn quote_builder_from_obj(reporter: &Reporter, objects: &Objects, obj: &Object)
}
}
} else {
let quoted_many = obj.scope().is_none().then(|| {
let method_name_many = format_ident!("with_many_{field_name}");
let docstring_many = unindent::unindent(&format!("\
This method makes it possible to pack multiple [`{typ}`] in a single component batch.
This only makes sense when used in conjunction with [`Self::columns`]. [`Self::{method_name}`] should
be used when logging a single row's worth of data.
"));
let docstring_many = quote_doc_lines(&docstring_many.lines().map(|l| l.to_owned()).collect_vec());

quote !{
#docstring_many
#[inline]
pub fn #method_name_many(mut self, #field_name: impl IntoIterator<Item = impl Into<#typ>>) -> Self {
self.#field_name = try_serialize_field(Self::#descr_fn_name(), #field_name);
self
}
}
});

quote! {
#docstring
#[inline]
pub fn #method_name(mut self, #field_name: impl Into<#typ>) -> Self {
self.#field_name = try_serialize_field(Self::#descr_fn_name(), [#field_name]);
self
}

#quoted_many
}
}
});
Expand Down
26 changes: 26 additions & 0 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.

13 changes: 13 additions & 0 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.

26 changes: 26 additions & 0 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.

13 changes: 13 additions & 0 deletions crates/store/re_types/src/archetypes/capsules3d.rs

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

92 changes: 92 additions & 0 deletions crates/store/re_types/src/archetypes/depth_image.rs

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

26 changes: 26 additions & 0 deletions crates/store/re_types/src/archetypes/ellipsoids3d.rs

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

Loading

0 comments on commit 85ba0dc

Please sign in to comment.