Skip to content

Commit

Permalink
Add datatype to component reflection and use it (preferred) for place…
Browse files Browse the repository at this point in the history
…holders (#7944)

### What

* Fixes #7940

Tested by removing the fallback provider for `ShowLabels` from points
which prior to this fix exhibits the same issue as above

### 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/7944?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/7944?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)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7944)
- [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`.
  • Loading branch information
Wumpf authored Oct 30, 2024
1 parent 413f7a1 commit ed39d96
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ fn generate_component_reflection(
let quoted_reflection = quote! {
ComponentReflection {
docstring_md: #docstring_md,

custom_placeholder: #custom_placeholder,
datatype: #type_name::arrow_datatype(),
}
};
quoted_pairs.push(quote! { (#quoted_name, #quoted_reflection) });
Expand Down
8 changes: 0 additions & 8 deletions crates/store/re_types_core/src/loggable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,6 @@ pub trait Loggable: 'static + Send + Sync + Clone + Sized + SizeBytes {
///
/// Any [`Loggable`] with a [`Loggable::Name`] set to [`ComponentName`] automatically implements
/// [`Component`].
///
/// All built-in components should implement the [`Default`] trait, so that the Viewer has a placeholder
/// value that it can display for ui editors in absence of a value.
/// In absence of an obvious default value, they should be implemented such that they are versatile
/// and informative for the user when using the viewer.
///
/// This is not enforced via a trait bound, since it's only necessary for components known to the Rerun Viewer.
/// It is not a hard requirement for custom components that are only used on the SDK side.
pub trait Component: Loggable<Name = ComponentName> {}

impl<L: Loggable<Name = ComponentName>> Component for L {}
Expand Down
3 changes: 3 additions & 0 deletions crates/store/re_types_core/src/reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ pub struct ComponentReflection {
/// Typically, this is only used when `FallbackProvider`s are not available.
/// If there's no custom placeholder, a placeholder can be derived from the arrow datatype.
pub custom_placeholder: Option<Box<dyn arrow2::array::Array>>,

/// Datatype of the component.
pub datatype: arrow2::datatypes::DataType,
}

/// Runtime reflection about archetypes.
Expand Down
Loading

0 comments on commit ed39d96

Please sign in to comment.