diff --git a/Cargo.lock b/Cargo.lock index 06ef15ba16f0..927ed6876abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3936,6 +3936,7 @@ dependencies = [ "re_log", "re_log_types", "re_tracing", + "re_types", "smallvec", "thiserror", "tinyvec", @@ -4034,6 +4035,7 @@ dependencies = [ "re_log_types", "re_smart_channel", "re_tracing", + "re_types", "serde", "thiserror", ] @@ -4059,6 +4061,7 @@ dependencies = [ "re_query", "re_renderer", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "rfd", @@ -4197,6 +4200,7 @@ dependencies = [ "itertools 0.11.0", "mimalloc", "polars-core", + "rand", "re_arrow_store", "re_components", "re_data_store", @@ -4339,6 +4343,7 @@ dependencies = [ "re_renderer", "re_space_view", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "vec1", @@ -4400,6 +4405,7 @@ dependencies = [ "re_space_view", "re_tensor_ops", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "thiserror", @@ -4424,6 +4430,7 @@ dependencies = [ "re_renderer", "re_space_view", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "vec1", @@ -4440,6 +4447,7 @@ dependencies = [ "re_query", "re_renderer", "re_space_view", + "re_types", "re_ui", "re_viewer_context", "vec1", @@ -4459,6 +4467,7 @@ dependencies = [ "re_renderer", "re_space_view", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "vec1", @@ -4540,11 +4549,16 @@ dependencies = [ "glam", "itertools 0.11.0", "macaw", + "nohash-hasher", + "once_cell", "rayon", "re_build_tools", "re_error", + "re_string_interner", "re_types_builder", + "serde", "similar-asserts", + "smallvec", "thiserror", ] @@ -4632,6 +4646,7 @@ dependencies = [ "re_space_view_time_series", "re_time_panel", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "re_viewport", @@ -4673,6 +4688,7 @@ dependencies = [ "re_renderer", "re_string_interner", "re_tracing", + "re_types", "re_ui", "serde", "slotmap", @@ -4705,6 +4721,7 @@ dependencies = [ "re_renderer", "re_space_view", "re_tracing", + "re_types", "re_ui", "re_viewer_context", "serde", @@ -4862,6 +4879,7 @@ dependencies = [ "parking_lot 0.12.1", "re_log", "re_sdk", + "re_types", ] [[package]] diff --git a/crates/re_arrow_store/Cargo.toml b/crates/re_arrow_store/Cargo.toml index 7a286055c505..badb1199a104 100644 --- a/crates/re_arrow_store/Cargo.toml +++ b/crates/re_arrow_store/Cargo.toml @@ -36,6 +36,7 @@ re_format.workspace = true re_log_types.workspace = true re_log.workspace = true re_tracing.workspace = true +re_types.workspace = true # External dependencies: ahash.workspace = true diff --git a/crates/re_arrow_store/benches/arrow2.rs b/crates/re_arrow_store/benches/arrow2.rs index a1f46e11531c..578591987101 100644 --- a/crates/re_arrow_store/benches/arrow2.rs +++ b/crates/re_arrow_store/benches/arrow2.rs @@ -12,10 +12,8 @@ use re_components::{ datagen::{build_some_instances, build_some_point2d, build_some_rects}, Point2D, Rect2D, }; -use re_log_types::{ - external::arrow2_convert::serialize::TryIntoArrow, DataCell, InstanceKey, - SerializableComponent, SizeBytes as _, -}; +use re_log_types::{DataCell, SizeBytes as _}; +use re_types::{components::InstanceKey, Component}; // --- @@ -98,13 +96,14 @@ fn erased_clone(c: &mut Criterion) { } // TODO(cmc): Use cells once `cell.size_bytes()` has landed (#1727) - fn bench_arrow( + fn bench_arrow<'a, T: Component + 'a>( group: &mut criterion::BenchmarkGroup<'_, criterion::measurement::WallTime>, - data: &[T], - ) { - let arrays: Vec> = (0..NUM_ROWS) - .map(|_| TryIntoArrow::try_into_arrow(data).unwrap()) - .collect_vec(); + data: &'a [T], + ) where + &'a T: Into<::std::borrow::Cow<'a, T>>, + { + let arrays: Vec> = + (0..NUM_ROWS).map(|_| T::to_arrow(data, None)).collect_vec(); let total_size_bytes = arrays .iter() diff --git a/crates/re_arrow_store/benches/arrow2_convert.rs b/crates/re_arrow_store/benches/arrow2_convert.rs index 1afe46bcf266..c349746ff3d9 100644 --- a/crates/re_arrow_store/benches/arrow2_convert.rs +++ b/crates/re_arrow_store/benches/arrow2_convert.rs @@ -5,9 +5,8 @@ static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc; use arrow2::{array::PrimitiveArray, datatypes::PhysicalType, types::PrimitiveType}; use criterion::{criterion_group, Criterion}; -use re_log_types::{ - external::arrow2_convert::deserialize::TryIntoCollection, Component as _, DataCell, InstanceKey, -}; +use re_log_types::DataCell; +use re_types::{components::InstanceKey, Loggable as _}; // --- @@ -99,7 +98,7 @@ fn deserialize(c: &mut Criterion) { { group.bench_function("arrow2_convert", |b| { b.iter(|| { - let keys: Vec = data.as_ref().try_into_collection().unwrap(); + let keys: Vec = InstanceKey::from_arrow(data.as_ref()); assert_eq!(NUM_INSTANCES, keys.len()); assert_eq!( InstanceKey(NUM_INSTANCES as u64 / 2), diff --git a/crates/re_arrow_store/benches/data_store.rs b/crates/re_arrow_store/benches/data_store.rs index 82855a598ed9..8e213e3fbc95 100644 --- a/crates/re_arrow_store/benches/data_store.rs +++ b/crates/re_arrow_store/benches/data_store.rs @@ -12,10 +12,8 @@ use re_components::{ datagen::{build_frame_nr, build_some_instances, build_some_rects}, Rect2D, }; -use re_log_types::{ - Component as _, ComponentName, DataCell, DataRow, DataTable, EntityPath, InstanceKey, RowId, - TableId, TimeType, Timeline, -}; +use re_log_types::{DataCell, DataRow, DataTable, EntityPath, RowId, TableId, TimeType, Timeline}; +use re_types::{components::InstanceKey, ComponentName, Loggable as _}; criterion_group!(benches, insert, latest_at, latest_at_missing, range, gc); criterion_main!(benches); diff --git a/crates/re_arrow_store/examples/dump_dataframe.rs b/crates/re_arrow_store/examples/dump_dataframe.rs index cb79aa96f07e..44e695301cf0 100644 --- a/crates/re_arrow_store/examples/dump_dataframe.rs +++ b/crates/re_arrow_store/examples/dump_dataframe.rs @@ -9,7 +9,8 @@ use re_components::datagen::{ build_frame_nr, build_log_time, build_some_instances, build_some_instances_from, build_some_point2d, build_some_rects, }; -use re_log_types::{Component as _, EntityPath, InstanceKey, Time}; +use re_log_types::{EntityPath, Time}; +use re_types::{components::InstanceKey, Loggable}; // --- diff --git a/crates/re_arrow_store/examples/latest_component.rs b/crates/re_arrow_store/examples/latest_component.rs index b32ca0e02350..4c859e4966c4 100644 --- a/crates/re_arrow_store/examples/latest_component.rs +++ b/crates/re_arrow_store/examples/latest_component.rs @@ -10,7 +10,8 @@ use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, Point2D, Rect2D, }; -use re_log_types::{Component, EntityPath, InstanceKey}; +use re_log_types::EntityPath; +use re_types::{components::InstanceKey, Loggable}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/latest_components.rs b/crates/re_arrow_store/examples/latest_components.rs index d623492fdf7d..b1023d548816 100644 --- a/crates/re_arrow_store/examples/latest_components.rs +++ b/crates/re_arrow_store/examples/latest_components.rs @@ -12,7 +12,8 @@ use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, Point2D, Rect2D, }; -use re_log_types::{Component, EntityPath, InstanceKey}; +use re_log_types::EntityPath; +use re_types::{components::InstanceKey, Loggable}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/examples/range_components.rs b/crates/re_arrow_store/examples/range_components.rs index f9bd8e69c25d..14e71b0398cc 100644 --- a/crates/re_arrow_store/examples/range_components.rs +++ b/crates/re_arrow_store/examples/range_components.rs @@ -10,7 +10,8 @@ use re_components::{ datagen::{build_frame_nr, build_some_point2d, build_some_rects}, Point2D, Rect2D, }; -use re_log_types::{Component as _, EntityPath, InstanceKey, TimeType, Timeline}; +use re_log_types::{EntityPath, TimeType, Timeline}; +use re_types::{components::InstanceKey, Loggable}; fn main() { let mut store = DataStore::new(InstanceKey::name(), Default::default()); diff --git a/crates/re_arrow_store/src/arrow_util.rs b/crates/re_arrow_store/src/arrow_util.rs index ea7eb51f2f84..ad2a9511f787 100644 --- a/crates/re_arrow_store/src/arrow_util.rs +++ b/crates/re_arrow_store/src/arrow_util.rs @@ -249,8 +249,10 @@ mod tests { Vec3D(Vec3D), } - impl re_log_types::Component for TestComponentWithUnionAndFixedSizeList { - fn name() -> re_log_types::ComponentName { + re_log_types::component_legacy_shim!(TestComponentWithUnionAndFixedSizeList); + + impl re_log_types::LegacyComponent for TestComponentWithUnionAndFixedSizeList { + fn legacy_name() -> re_log_types::ComponentName { "test_component_with_union_and_fixed_size_list".into() } } diff --git a/crates/re_arrow_store/src/polars_util.rs b/crates/re_arrow_store/src/polars_util.rs index e70aa8541942..ff963abbc0ed 100644 --- a/crates/re_arrow_store/src/polars_util.rs +++ b/crates/re_arrow_store/src/polars_util.rs @@ -1,7 +1,8 @@ use itertools::Itertools; use polars_core::{prelude::*, series::Series}; use polars_ops::prelude::*; -use re_log_types::{ComponentName, DataCell, EntityPath, RowId, TimeInt}; +use re_log_types::{DataCell, EntityPath, RowId, TimeInt}; +use re_types::ComponentName; use crate::{ArrayExt, DataStore, LatestAtQuery, RangeQuery}; @@ -139,7 +140,7 @@ pub fn range_components<'a, const N: usize>( if df.as_ref().map_or(false, |df| { // We only care about the initial state if it A) isn't empty and B) contains any data // at all for the primary component. - !df.is_empty() && df.column(primary.as_str()).is_ok() + !df.is_empty() && df.column(primary.as_ref()).is_ok() }) { df_latest = Some(df); } @@ -186,8 +187,9 @@ pub fn range_components<'a, const N: usize>( let df = df .select( components + .clone() .iter() - .filter(|col| columns.contains(&col.as_str())), + .filter(|col| columns.contains(&col.as_ref())), ) .unwrap(); (time, df) @@ -207,7 +209,7 @@ pub fn dataframe_from_cells( .flatten() .map(|cell| { Series::try_from(( - cell.component_name().as_str(), + cell.component_name().as_ref(), cell.as_arrow_ref().clean_for_polars(), )) }) @@ -239,15 +241,15 @@ pub fn join_dataframes( for col in right .get_column_names() .iter() - .filter(|col| *col != &cluster_key.as_str()) + .filter(|col| *col != &cluster_key) { _ = left.drop_in_place(col); } left.join( &right, - [cluster_key.as_str()], - [cluster_key.as_str()], + [cluster_key], + [cluster_key], join_type.clone(), None, ) diff --git a/crates/re_arrow_store/src/store.rs b/crates/re_arrow_store/src/store.rs index f87d63ae1350..3989e6e19e00 100644 --- a/crates/re_arrow_store/src/store.rs +++ b/crates/re_arrow_store/src/store.rs @@ -5,11 +5,12 @@ use ahash::HashMap; use arrow2::datatypes::DataType; use nohash_hasher::{IntMap, IntSet}; use parking_lot::RwLock; +use re_types::ComponentName; use smallvec::SmallVec; use re_log_types::{ - ComponentName, DataCell, DataCellColumn, EntityPath, EntityPathHash, ErasedTimeVec, - NumInstancesVec, RowId, RowIdVec, SizeBytes, TimeInt, TimePoint, TimeRange, Timeline, + DataCell, DataCellColumn, EntityPath, EntityPathHash, ErasedTimeVec, NumInstancesVec, RowId, + RowIdVec, SizeBytes, TimeInt, TimePoint, TimeRange, Timeline, }; // --- Data store --- @@ -284,7 +285,7 @@ impl DataStore { &self.config } - /// Lookup the arrow [`DataType`] of a [`re_log_types::Component`] in the internal + /// Lookup the arrow [`DataType`] of a [`re_types::Component`] in the internal /// `DataTypeRegistry`. pub fn lookup_datatype(&self, component: &ComponentName) -> Option<&DataType> { self.type_registry.get(component) @@ -335,7 +336,7 @@ impl DataStore { #[test] fn datastore_internal_repr() { use re_components::datagen::data_table_example; - use re_log_types::{Component as _, InstanceKey}; + use re_types::{components::InstanceKey, Loggable as _}; let mut store = DataStore::new( InstanceKey::name(), diff --git a/crates/re_arrow_store/src/store_arrow.rs b/crates/re_arrow_store/src/store_arrow.rs index 99cd3f5996e3..737b017b59b4 100644 --- a/crates/re_arrow_store/src/store_arrow.rs +++ b/crates/re_arrow_store/src/store_arrow.rs @@ -3,9 +3,10 @@ use std::collections::BTreeMap; use arrow2::{array::Array, chunk::Chunk, datatypes::Schema}; use nohash_hasher::IntMap; use re_log_types::{ - ComponentName, DataCellColumn, DataTable, DataTableResult, RowId, Timeline, COLUMN_INSERT_ID, + DataCellColumn, DataTable, DataTableResult, RowId, Timeline, COLUMN_INSERT_ID, COLUMN_NUM_INSTANCES, COLUMN_ROW_ID, }; +use re_types::ComponentName; use crate::store::{IndexedBucket, IndexedBucketInner, PersistentIndexedTable}; @@ -188,8 +189,7 @@ fn serialize_data_columns( // NOTE: cannot fail, the cluster key _has_ to be there by definition let cluster_column = table.remove(&cluster_key).unwrap(); { - let (field, column) = - DataTable::serialize_data_column(cluster_key.as_str(), cluster_column)?; + let (field, column) = DataTable::serialize_data_column(cluster_key, cluster_column)?; schema.fields.push(field); columns.push(column); } @@ -197,7 +197,7 @@ fn serialize_data_columns( for (component, column) in table { // NOTE: Don't serialize columns with only null values. if column.iter().any(Option::is_some) { - let (field, column) = DataTable::serialize_data_column(component.as_str(), column)?; + let (field, column) = DataTable::serialize_data_column(component, column)?; schema.fields.push(field); columns.push(column); } diff --git a/crates/re_arrow_store/src/store_helpers.rs b/crates/re_arrow_store/src/store_helpers.rs index 8992390fb375..24338b71f97d 100644 --- a/crates/re_arrow_store/src/store_helpers.rs +++ b/crates/re_arrow_store/src/store_helpers.rs @@ -1,14 +1,13 @@ -use re_log_types::{ - ComponentName, DataCell, DataRow, DeserializableComponent, EntityPath, RowId, - SerializableComponent, TimePoint, Timeline, -}; +use re_log_types::{DataCell, DataRow, EntityPath, RowId, TimePoint, Timeline}; + +use re_types::{Component, ComponentName}; use crate::{DataStore, LatestAtQuery}; // --- Read --- impl DataStore { - /// Get the latest value for a given [`re_log_types::Component`]. + /// Get the latest value for a given [`re_types::Component`]. /// /// This assumes that the row we get from the store only contains a single instance for this /// component; it will log a warning otherwise. @@ -16,14 +15,11 @@ impl DataStore { /// This should only be used for "mono-components" such as `Transform` and `Tensor`. /// /// This is a best-effort helper, it will merely log errors on failure. - pub fn query_latest_component( + pub fn query_latest_component( &self, entity_path: &EntityPath, query: &LatestAtQuery, - ) -> Option - where - for<'b> &'b C::ArrayType: IntoIterator, - { + ) -> Option { re_tracing::profile_function!(); let (_, cells) = self.latest_at(query, entity_path, C::name(), &[C::name()])?; @@ -49,14 +45,11 @@ impl DataStore { } /// Call `query_latest_component` at the given path, walking up the hierarchy until an instance is found. - pub fn query_latest_component_at_closest_ancestor( + pub fn query_latest_component_at_closest_ancestor( &self, entity_path: &EntityPath, query: &LatestAtQuery, - ) -> Option<(EntityPath, C)> - where - for<'b> &'b C::ArrayType: IntoIterator, - { + ) -> Option<(EntityPath, C)> { re_tracing::profile_function!(); let mut cur_path = Some(entity_path.clone()); @@ -69,7 +62,7 @@ impl DataStore { None } - /// Get the latest value for a given [`re_log_types::Component`], assuming it is timeless. + /// Get the latest value for a given [`re_types::Component`], assuming it is timeless. /// /// This assumes that the row we get from the store only contains a single instance for this /// component; it will log a warning otherwise. @@ -77,13 +70,7 @@ impl DataStore { /// This should only be used for "mono-components" such as `Transform` and `Tensor`. /// /// This is a best-effort helper, it will merely log errors on failure. - pub fn query_timeless_component( - &self, - entity_path: &EntityPath, - ) -> Option - where - for<'b> &'b C::ArrayType: IntoIterator, - { + pub fn query_timeless_component(&self, entity_path: &EntityPath) -> Option { re_tracing::profile_function!(); let query = LatestAtQuery::latest(Timeline::default()); @@ -94,15 +81,18 @@ impl DataStore { // --- Write --- impl DataStore { - /// Stores a single value for a given [`re_log_types::Component`]. + /// Stores a single value for a given [`re_types::Component`]. /// /// This is a best-effort helper, it will merely log errors on failure. - pub fn insert_component( + pub fn insert_component<'a, C>( &mut self, entity_path: &EntityPath, timepoint: &TimePoint, component: C, - ) { + ) where + C: Component + Clone + 'a, + std::borrow::Cow<'a, C>: std::convert::From, + { re_tracing::profile_function!(); let mut row = match DataRow::try_from_cells1( @@ -110,7 +100,7 @@ impl DataStore { entity_path.clone(), timepoint.clone(), 1, - [component].as_slice(), + [component], ) { Ok(row) => row, Err(err) => { diff --git a/crates/re_arrow_store/src/store_polars.rs b/crates/re_arrow_store/src/store_polars.rs index 9dc52ab9c6b7..780bf6f111cf 100644 --- a/crates/re_arrow_store/src/store_polars.rs +++ b/crates/re_arrow_store/src/store_polars.rs @@ -9,7 +9,8 @@ use arrow2::{ offset::Offsets, }; use polars_core::{functions::diag_concat_df, prelude::*}; -use re_log_types::{ComponentName, DataCell, DataTable}; +use re_log_types::{DataCell, DataTable}; +use re_types::ComponentName; use crate::{ store::InsertIdVec, ArrayExt, DataStore, DataStoreConfig, IndexedBucket, IndexedBucketInner, @@ -118,7 +119,7 @@ impl DataStore { let df = sort_df_columns(&df, self.config.store_insert_ids, &timelines); let has_timeless = df.column(TIMELESS_COL).is_ok(); - let insert_id_col = DataStore::insert_id_key().as_str(); + let insert_id_col = DataStore::insert_id_key(); const ASCENDING: bool = false; const DESCENDING: bool = true; @@ -130,9 +131,9 @@ impl DataStore { df.column(TIMELESS_COL) .is_ok() .then_some((TIMELESS_COL, DESCENDING)), - df.column(insert_id_col) + df.column(insert_id_col.as_ref()) .is_ok() - .then_some((insert_id_col, ASCENDING)), + .then_some((insert_id_col.as_ref(), ASCENDING)), ] .into_iter() .flatten() @@ -263,7 +264,7 @@ fn insert_ids_as_series(col_insert_id: &InsertIdVec) -> Series { let insert_ids = arrow2::array::UInt64Array::from_slice(col_insert_id.as_slice()); new_infallible_series( - DataStore::insert_id_key().as_str(), + DataStore::insert_id_key().as_ref(), &insert_ids, insert_ids.len(), ) @@ -309,7 +310,7 @@ fn column_as_series( Some(Bitmap::from(comp_validity)), ); - new_infallible_series(component.as_str(), &comp_values, num_rows) + new_infallible_series(component.as_ref(), &comp_values, num_rows) } // --- diff --git a/crates/re_arrow_store/src/store_read.rs b/crates/re_arrow_store/src/store_read.rs index 2b036e48ad7d..5eb3b953635c 100644 --- a/crates/re_arrow_store/src/store_read.rs +++ b/crates/re_arrow_store/src/store_read.rs @@ -3,9 +3,8 @@ use std::{ops::RangeBounds, sync::atomic::Ordering}; use itertools::Itertools; use nohash_hasher::IntSet; use re_log::trace; -use re_log_types::{ - ComponentName, DataCell, EntityPath, RowId, TimeInt, TimePoint, TimeRange, Timeline, -}; +use re_log_types::{DataCell, EntityPath, RowId, TimeInt, TimePoint, TimeRange, Timeline}; +use re_types::ComponentName; use smallvec::SmallVec; use crate::{DataStore, IndexedBucket, IndexedBucketInner, IndexedTable, PersistentIndexedTable}; @@ -111,7 +110,7 @@ impl DataStore { let timeless: Option> = self .timeless_tables .get(&ent_path_hash) - .map(|table| table.columns.keys().copied().collect()); + .map(|table| table.columns.keys().cloned().collect()); let temporal = self .tables @@ -158,7 +157,8 @@ impl DataStore { /// /// ```rust /// # use polars_core::{prelude::*, series::Series}; - /// # use re_log_types::{ComponentName, EntityPath, RowId, TimeInt}; + /// # use re_log_types::{EntityPath, RowId, TimeInt}; + /// # use re_types::{ComponentName}; /// # use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery}; /// # /// pub fn latest_component( @@ -327,8 +327,9 @@ impl DataStore { /// ```rust /// # use arrow2::array::Array; /// # use polars_core::{prelude::*, series::Series}; - /// # use re_log_types::{ComponentName, DataCell, EntityPath, RowId, TimeInt}; + /// # use re_log_types::{DataCell, EntityPath, RowId, TimeInt}; /// # use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery}; + /// # use re_types::ComponentName; /// # /// # pub fn dataframe_from_cells( /// # cells: [Option; N], @@ -338,7 +339,7 @@ impl DataStore { /// # .flatten() /// # .map(|cell| { /// # Series::try_from(( - /// # cell.component_name().as_str(), + /// # cell.component_name().as_ref(), /// # cell.to_arrow(), /// # )) /// # }) diff --git a/crates/re_arrow_store/src/store_sanity.rs b/crates/re_arrow_store/src/store_sanity.rs index 0c5aa5f8be58..6eea630e2f70 100644 --- a/crates/re_arrow_store/src/store_sanity.rs +++ b/crates/re_arrow_store/src/store_sanity.rs @@ -1,7 +1,8 @@ use re_log_types::{ - ComponentName, DataCellColumn, SizeBytes as _, TimeRange, COLUMN_NUM_INSTANCES, COLUMN_ROW_ID, + DataCellColumn, SizeBytes as _, TimeRange, COLUMN_NUM_INSTANCES, COLUMN_ROW_ID, COLUMN_TIMEPOINT, }; +use re_types::ComponentName; use crate::{DataStore, IndexedBucket, IndexedBucketInner, IndexedTable, PersistentIndexedTable}; diff --git a/crates/re_arrow_store/src/store_stats.rs b/crates/re_arrow_store/src/store_stats.rs index e3affdb89c90..e84e7dff7841 100644 --- a/crates/re_arrow_store/src/store_stats.rs +++ b/crates/re_arrow_store/src/store_stats.rs @@ -1,5 +1,6 @@ use nohash_hasher::IntMap; -use re_log_types::{ComponentName, SizeBytes, TimePoint}; +use re_log_types::{SizeBytes, TimePoint}; +use re_types::ComponentName; use crate::{ store::IndexedBucketInner, ClusterCellCache, DataStore, DataTypeRegistry, IndexedBucket, diff --git a/crates/re_arrow_store/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index cb04fa9dbca5..526c16eb715c 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -6,9 +6,10 @@ use smallvec::SmallVec; use re_log::{debug, trace}; use re_log_types::{ - ComponentName, DataCell, DataCellColumn, DataCellError, DataRow, DataTable, InstanceKey, RowId, - SizeBytes as _, TimeInt, TimePoint, TimeRange, + DataCell, DataCellColumn, DataCellError, DataRow, DataTable, RowId, SizeBytes as _, TimeInt, + TimePoint, TimeRange, }; +use re_types::{components::InstanceKey, ComponentName, Loggable}; use crate::{ store::MetadataRegistry, DataStore, DataStoreConfig, IndexedBucket, IndexedBucketInner, @@ -215,7 +216,6 @@ impl DataStore { // let cell = DataCell::from_component::(0..len as u64); // ...so we create it manually instead. - use re_log_types::Component as _; let values = arrow2::array::UInt64Array::from_vec((0..num_instances as u64).collect_vec()) .boxed(); diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 01839d5ba34f..7357bbead031 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -13,9 +13,8 @@ use re_arrow_store::{ use re_components::datagen::{ build_frame_nr, build_log_time, build_some_colors, build_some_instances, build_some_point2d, }; -use re_log_types::{ - Component as _, DataCell, Duration, EntityPath, InstanceKey, Time, TimeType, Timeline, -}; +use re_log_types::{DataCell, Duration, EntityPath, Time, TimeType, Timeline}; +use re_types::{components::InstanceKey, Loggable as _}; // --- @@ -214,13 +213,11 @@ fn range_join_across_single_row() { #[cfg(feature = "polars")] fn range_join_across_single_row_impl(store: &mut DataStore) { - use arrow2::array::Array; use polars_core::{ prelude::{DataFrame, JoinType}, series::Series, }; use re_components::{ColorRGBA, Point2D}; - use re_log_types::external::arrow2_convert::serialize::TryIntoArrow as _; let ent_path = EntityPath::from("this/that"); @@ -247,16 +244,15 @@ fn range_join_across_single_row_impl(store: &mut DataStore) { .collect::>(); let df_expected = { - let instances: Box = vec![InstanceKey(0), InstanceKey(1), InstanceKey(2)] - .try_into_arrow() - .unwrap(); - let points: Box = points.try_into_arrow().unwrap(); - let colors: Box = colors.try_into_arrow().unwrap(); + let instances = + InstanceKey::to_arrow(vec![InstanceKey(0), InstanceKey(1), InstanceKey(2)], None); + let points = Point2D::to_arrow(points, None); + let colors = ColorRGBA::to_arrow(colors, None); DataFrame::new(vec![ - Series::try_from((InstanceKey::name().as_str(), instances)).unwrap(), - Series::try_from((Point2D::name().as_str(), points)).unwrap(), - Series::try_from((ColorRGBA::name().as_str(), colors)).unwrap(), + Series::try_from((InstanceKey::name().as_ref(), instances)).unwrap(), + Series::try_from((Point2D::name().as_ref(), points)).unwrap(), + Series::try_from((ColorRGBA::name().as_ref(), colors)).unwrap(), ]) .unwrap() }; diff --git a/crates/re_arrow_store/tests/data_store.rs b/crates/re_arrow_store/tests/data_store.rs index b17aaa72da84..1413eb028c37 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -21,10 +21,8 @@ use re_components::{ }, ColorRGBA, InstanceKey, Point2D, Rect2D, }; -use re_log_types::{ - Component as _, ComponentName, DataCell, DataRow, DataTable, EntityPath, TableId, TimeType, - Timeline, -}; +use re_log_types::{DataCell, DataRow, DataTable, EntityPath, TableId, TimeType, Timeline}; +use re_types::{ComponentName, Loggable as _}; // --- LatestComponentsAt --- @@ -804,12 +802,12 @@ fn joint_df(cluster_key: ComponentName, rows: &[(ComponentName, &DataRow)]) -> D .iter() .map(|(component, row)| { let cluster_comp = if let Some(idx) = row.find_cell(&cluster_key) { - Series::try_from((cluster_key.as_str(), row.cells[idx].to_arrow_monolist())) + Series::try_from((cluster_key.as_ref(), row.cells[idx].to_arrow_monolist())) .unwrap() } else { let num_instances = row.num_instances(); Series::try_from(( - cluster_key.as_str(), + cluster_key.as_ref(), DataCell::from_component::(0..num_instances as u64) .to_arrow_monolist(), )) @@ -819,7 +817,7 @@ fn joint_df(cluster_key: ComponentName, rows: &[(ComponentName, &DataRow)]) -> D let comp_idx = row.find_cell(component).unwrap(); let df = DataFrame::new(vec![ cluster_comp, - Series::try_from((component.as_str(), row.cells[comp_idx].to_arrow_monolist())) + Series::try_from((component.as_ref(), row.cells[comp_idx].to_arrow_monolist())) .unwrap(), ]) .unwrap(); @@ -827,14 +825,14 @@ fn joint_df(cluster_key: ComponentName, rows: &[(ComponentName, &DataRow)]) -> D df.explode(df.get_column_names()).unwrap() }) .reduce(|left, right| { - left.outer_join(&right, [cluster_key.as_str()], [cluster_key.as_str()]) + left.outer_join(&right, [cluster_key.as_ref()], [cluster_key.as_ref()]) .unwrap() }) .unwrap_or_default(); let df = polars_util::drop_all_nulls(&df, &cluster_key).unwrap(); - df.sort([cluster_key.as_str()], false).unwrap_or(df) + df.sort([cluster_key.as_ref()], false).unwrap_or(df) } // --- GC --- diff --git a/crates/re_arrow_store/tests/dump.rs b/crates/re_arrow_store/tests/dump.rs index 336e1042f073..3ad7e21f5b21 100644 --- a/crates/re_arrow_store/tests/dump.rs +++ b/crates/re_arrow_store/tests/dump.rs @@ -10,7 +10,8 @@ use re_arrow_store::{ use re_components::datagen::{ build_frame_nr, build_log_time, build_some_colors, build_some_instances, build_some_point2d, }; -use re_log_types::{Component as _, DataTable, EntityPath, InstanceKey, TableId}; +use re_log_types::{DataTable, EntityPath, TableId}; +use re_types::{components::InstanceKey, Loggable as _}; // --- Dump --- diff --git a/crates/re_arrow_store/tests/internals.rs b/crates/re_arrow_store/tests/internals.rs index 10c9cc3ffffc..87937c2563ab 100644 --- a/crates/re_arrow_store/tests/internals.rs +++ b/crates/re_arrow_store/tests/internals.rs @@ -6,7 +6,8 @@ use std::sync::atomic::{AtomicBool, Ordering::SeqCst}; use re_arrow_store::{DataStore, DataStoreConfig}; use re_components::datagen::{build_frame_nr, build_some_instances}; -use re_log_types::{Component as _, DataRow, EntityPath, InstanceKey, RowId, TimePoint}; +use re_log_types::{DataRow, EntityPath, RowId, TimePoint}; +use re_types::{components::InstanceKey, Loggable as _}; // --- Internals --- diff --git a/crates/re_components/src/arrow.rs b/crates/re_components/src/arrow.rs index d1b42c54f170..ca9d00c37773 100644 --- a/crates/re_components/src/arrow.rs +++ b/crates/re_components/src/arrow.rs @@ -35,13 +35,15 @@ pub struct Arrow3D { pub vector: Vec3D, } -impl re_log_types::Component for Arrow3D { +impl re_log_types::LegacyComponent for Arrow3D { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.arrow3d".into() } } +re_log_types::component_legacy_shim!(Arrow3D); + #[test] fn test_arrow3d_roundtrip() { use arrow2::array::Array; diff --git a/crates/re_components/src/bbox.rs b/crates/re_components/src/bbox.rs index 91d68abe77a8..965332ad1b00 100644 --- a/crates/re_components/src/bbox.rs +++ b/crates/re_components/src/bbox.rs @@ -37,9 +37,9 @@ impl Box3D { } } -impl re_log_types::Component for Box3D { +impl re_log_types::LegacyComponent for Box3D { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.box3d".into() } } @@ -109,3 +109,5 @@ impl ArrowDeserialize for Box3D { }) } } + +re_log_types::component_legacy_shim!(Box3D); diff --git a/crates/re_components/src/class_id.rs b/crates/re_components/src/class_id.rs index a049baa0d864..ee40da03ef28 100644 --- a/crates/re_components/src/class_id.rs +++ b/crates/re_components/src/class_id.rs @@ -21,9 +21,9 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; #[arrow_field(transparent)] pub struct ClassId(pub u16); -impl re_log_types::Component for ClassId { +impl re_log_types::LegacyComponent for ClassId { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.class_id".into() } } @@ -33,3 +33,5 @@ impl From for ClassId { Self(other.0) } } + +re_log_types::component_legacy_shim!(ClassId); diff --git a/crates/re_components/src/color.rs b/crates/re_components/src/color.rs index 630850dbe150..92884d5e730b 100644 --- a/crates/re_components/src/color.rs +++ b/crates/re_components/src/color.rs @@ -59,9 +59,9 @@ impl From<[u8; 4]> for ColorRGBA { } } -impl re_log_types::Component for ColorRGBA { +impl re_log_types::LegacyComponent for ColorRGBA { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.colorrgba".into() } } @@ -74,6 +74,8 @@ impl From for ecolor::Color32 { } } +re_log_types::component_legacy_shim!(ColorRGBA); + #[test] fn test_colorrgba_roundtrip() { use arrow2::array::Array; diff --git a/crates/re_components/src/context.rs b/crates/re_components/src/context.rs index a93ac4e47b92..287e34207e7b 100644 --- a/crates/re_components/src/context.rs +++ b/crates/re_components/src/context.rs @@ -167,9 +167,9 @@ pub struct AnnotationContext { pub class_map: HashMap, } -impl re_log_types::Component for AnnotationContext { +impl re_log_types::LegacyComponent for AnnotationContext { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.annotation_context".into() } } @@ -245,6 +245,8 @@ impl ArrowDeserialize for AnnotationContext { } } +re_log_types::component_legacy_shim!(AnnotationContext); + #[test] fn test_context_roundtrip() { use arrow2::array::Array; diff --git a/crates/re_components/src/coordinates.rs b/crates/re_components/src/coordinates.rs index 4f8a262aaa82..97a6aabc6408 100644 --- a/crates/re_components/src/coordinates.rs +++ b/crates/re_components/src/coordinates.rs @@ -97,9 +97,9 @@ impl TryFrom for ViewDir { #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct ViewCoordinates(pub [ViewDir; 3]); -impl re_log_types::Component for ViewCoordinates { +impl re_log_types::LegacyComponent for ViewCoordinates { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.view_coordinates".into() } } @@ -377,6 +377,8 @@ impl ArrowDeserialize for ViewCoordinates { } } +re_log_types::component_legacy_shim!(ViewCoordinates); + // ---------------------------------------------------------------------------- /// One of `X`, `Y`, `Z`. diff --git a/crates/re_components/src/datagen.rs b/crates/re_components/src/datagen.rs index 7d819f423411..acbf203dc1e5 100644 --- a/crates/re_components/src/datagen.rs +++ b/crates/re_components/src/datagen.rs @@ -2,7 +2,8 @@ // TODO(#1810): It really is time for whole module to disappear. -use re_log_types::{InstanceKey, Time, TimeInt, TimeType, Timeline}; +use re_log_types::{Time, TimeInt, TimeType, Timeline}; +use re_types::components::InstanceKey; /// Create `len` dummy rectangles pub fn build_some_rects(len: usize) -> Vec { diff --git a/crates/re_components/src/disconnected_space.rs b/crates/re_components/src/disconnected_space.rs index 689d96765699..2765b3329b75 100644 --- a/crates/re_components/src/disconnected_space.rs +++ b/crates/re_components/src/disconnected_space.rs @@ -26,9 +26,11 @@ impl Default for DisconnectedSpace { } } -impl re_log_types::Component for DisconnectedSpace { +impl re_log_types::LegacyComponent for DisconnectedSpace { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.disconnected_space".into() } } + +re_log_types::component_legacy_shim!(DisconnectedSpace); diff --git a/crates/re_components/src/draw_order.rs b/crates/re_components/src/draw_order.rs index 72881cf40e38..2f0247e92f3b 100644 --- a/crates/re_components/src/draw_order.rs +++ b/crates/re_components/src/draw_order.rs @@ -36,9 +36,9 @@ impl DrawOrder { pub const DEFAULT_POINTS2D: DrawOrder = DrawOrder(30.0); } -impl re_log_types::Component for DrawOrder { +impl re_log_types::LegacyComponent for DrawOrder { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.draw_order".into() } } @@ -85,3 +85,5 @@ impl From for f32 { value.0 } } + +re_log_types::component_legacy_shim!(DrawOrder); diff --git a/crates/re_components/src/keypoint_id.rs b/crates/re_components/src/keypoint_id.rs index 3f625faa672e..b4e448b9bf22 100644 --- a/crates/re_components/src/keypoint_id.rs +++ b/crates/re_components/src/keypoint_id.rs @@ -23,9 +23,9 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; #[arrow_field(transparent)] pub struct KeypointId(pub u16); -impl re_log_types::Component for KeypointId { +impl re_log_types::LegacyComponent for KeypointId { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.keypoint_id".into() } } @@ -35,3 +35,5 @@ impl From for KeypointId { Self(other.0) } } + +re_log_types::component_legacy_shim!(KeypointId); diff --git a/crates/re_components/src/label.rs b/crates/re_components/src/label.rs index fa5dde5458d2..38aea0d5ecf9 100644 --- a/crates/re_components/src/label.rs +++ b/crates/re_components/src/label.rs @@ -21,9 +21,9 @@ impl Label { } } -impl re_log_types::Component for Label { +impl re_log_types::LegacyComponent for Label { #[inline] - fn name() -> re_log_types::ComponentName { + fn legacy_name() -> re_log_types::ComponentName { "rerun.label".into() } } @@ -63,3 +63,5 @@ impl std::ops::Deref for Label { self.as_str() } } + +re_log_types::component_legacy_shim!(Label); diff --git a/crates/re_components/src/lib.rs b/crates/re_components/src/lib.rs index 601327cbe121..9ceb5a73ee0d 100644 --- a/crates/re_components/src/lib.rs +++ b/crates/re_components/src/lib.rs @@ -96,10 +96,10 @@ pub use self::tensor::{TensorImageLoadError, TensorImageSaveError}; pub use self::load_file::{data_cell_from_file_path, data_cell_from_mesh_file_path, FromFileError}; // This is a component -pub use re_log_types::InstanceKey; +pub use re_types::components::InstanceKey; // This is very convenient to re-export -pub use re_log_types::Component; +pub use re_log_types::LegacyComponent; pub mod external { #[cfg(feature = "glam")] @@ -114,35 +114,35 @@ pub mod external { lazy_static! { //TODO(john): use a run-time type registry static ref FIELDS: [Field; 29] = [ - ::field(), - ::field(), - ::field(), - ::field(), - ::field(), - ::field(), - ::field(), - ::field(), - ::field(), -