Skip to content

Commit 424cf2e

Browse files
authored
ComponentBatch doesn't implement AsComponents anymore (#8820)
This makes it impossible to pass something implementing `ComponentBatch` (i.e. some native data that knows how to serialized itself into arrow component data) directly to `RecordingStream::log`. This forces the caller to either..: * explicitly opt into the low-level / component-level APIs via `my_data.serialized()`, which expose further custom-tagging facilities, or * use the archetype-level APIs instead, which handle tagging automatically. Similarly, this removes all the legacy support infrastructure that was needed to carry `ComponentBatch`es all the way to the logger: * `log_component_batches` * `AsComponents::as_component_batches` * `ComponentBatchCow`, `ComponentBatchCowWithDescriptor`, ... * etc I think this is all that's needed in order to..: * fix #8757 At the very least, it makes sure that existing code that used to log `ComponentBatch`es directly breaks at compile-time.
1 parent fd5628e commit 424cf2e

File tree

289 files changed

+863
-1035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+863
-1035
lines changed

crates/build/re_types_builder/src/codegen/rust/api.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn generate_object_file(
185185
code.push_str("use ::re_types_core::SerializationResult;\n");
186186
code.push_str("use ::re_types_core::{DeserializationResult, DeserializationError};\n");
187187
code.push_str("use ::re_types_core::{ComponentDescriptor, ComponentName};\n");
188-
code.push_str("use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor, SerializedComponentBatch};\n");
188+
code.push_str("use ::re_types_core::{ComponentBatch, SerializedComponentBatch};\n");
189189

190190
// NOTE: `TokenStream`s discard whitespacing information by definition, so we need to
191191
// inject some of our own when writing to file… while making sure that don't inject
@@ -1174,7 +1174,7 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
11741174

11751175
let all_component_batches = {
11761176
std::iter::once(quote! {
1177-
Self::indicator().serialized()
1177+
Some(Self::indicator())
11781178
})
11791179
.chain(obj.fields.iter().map(|obj_field| {
11801180
let field_name = format_ident!("{}", obj_field.name);
@@ -1244,9 +1244,9 @@ fn quote_trait_impls_for_archetype(obj: &Object) -> TokenStream {
12441244
}
12451245

12461246
#[inline]
1247-
fn indicator() -> ComponentBatchCowWithDescriptor<'static> {
1248-
static INDICATOR: #quoted_indicator_name = #quoted_indicator_name::DEFAULT;
1249-
ComponentBatchCowWithDescriptor::new(&INDICATOR as &dyn ::re_types_core::ComponentBatch)
1247+
fn indicator() -> SerializedComponentBatch {
1248+
#[allow(clippy::unwrap_used)] // There is no such thing as failing to serialize an indicator.
1249+
#quoted_indicator_name::DEFAULT.serialized().unwrap()
12501250
}
12511251

12521252
#[inline]
@@ -1665,8 +1665,7 @@ fn quote_builder_from_obj(reporter: &Reporter, objects: &Objects, obj: &Object)
16651665
I: IntoIterator<Item = usize> + Clone,
16661666
{
16671667
let columns = [ #(#fields),* ];
1668-
let indicator_column = #indicator_column;
1669-
Ok(columns.into_iter().chain([indicator_column]).flatten())
1668+
Ok(columns.into_iter().flatten().chain([#indicator_column]))
16701669
}
16711670

16721671
#columns_unary_doc

crates/store/re_data_loader/src/loader_archetype.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn load_video(
220220
std::iter::once((video_timeline, time_column)).collect(),
221221
[
222222
(
223-
VideoFrameReference::indicator().descriptor().into_owned(),
223+
VideoFrameReference::indicator().descriptor.clone(),
224224
video_frame_reference_indicators_list_array,
225225
),
226226
(

crates/store/re_log_types/src/example_components.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ impl MyPoints {
6767
impl re_types_core::Archetype for MyPoints {
6868
type Indicator = re_types_core::GenericIndicatorComponent<Self>;
6969

70+
fn indicator() -> SerializedComponentBatch {
71+
use re_types_core::ComponentBatch as _;
72+
// These is no such thing as failing to serialized an indicator.
73+
#[allow(clippy::unwrap_used)]
74+
Self::Indicator::default().serialized().unwrap()
75+
}
76+
7077
fn name() -> re_types_core::ArchetypeName {
7178
"example.MyPoints".into()
7279
}

crates/store/re_types/src/archetypes/annotation_context.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/arrows2d.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/arrows3d.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/asset3d.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/asset_video.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/bar_chart.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/store/re_types/src/archetypes/boxes2d.rs

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)