diff --git a/crates/re_arrow_store/benches/data_store.rs b/crates/re_arrow_store/benches/data_store.rs index 7ad044e94cd78..1ae7c0f02ef06 100644 --- a/crates/re_arrow_store/benches/data_store.rs +++ b/crates/re_arrow_store/benches/data_store.rs @@ -8,8 +8,8 @@ use re_arrow_store::{DataStore, DataStoreConfig, LatestAtQuery, RangeQuery, Time use re_log_types::{ component_types::{InstanceKey, Rect2D}, datagen::{build_frame_nr, build_some_instances, build_some_rects}, - msg_bundle::{try_build_msg_bundle2, Component as _, MsgBundle}, - ComponentName, EntityPath, MsgId, TimeType, Timeline, + msg_bundle::{try_build_msg_bundle2, MsgBundle}, + Component as _, ComponentName, EntityPath, MsgId, TimeType, Timeline, }; // --- diff --git a/crates/re_arrow_store/examples/dump_dataframe.rs b/crates/re_arrow_store/examples/dump_dataframe.rs index dba9306007229..0ec908b302fe9 100644 --- a/crates/re_arrow_store/examples/dump_dataframe.rs +++ b/crates/re_arrow_store/examples/dump_dataframe.rs @@ -11,8 +11,7 @@ use re_log_types::{ build_frame_nr, build_log_time, build_some_instances, build_some_instances_from, build_some_point2d, build_some_rects, }, - msg_bundle::Component as _, - EntityPath, Time, + Component as _, EntityPath, Time, }; // --- diff --git a/crates/re_arrow_store/examples/latest_component.rs b/crates/re_arrow_store/examples/latest_component.rs index 61f75d9ee7f47..16b441fe3a1e3 100644 --- a/crates/re_arrow_store/examples/latest_component.rs +++ b/crates/re_arrow_store/examples/latest_component.rs @@ -11,8 +11,7 @@ use re_log_types::datagen::build_some_rects; use re_log_types::{ component_types::{InstanceKey, Point2D}, datagen::{build_frame_nr, build_some_point2d}, - msg_bundle::Component, - EntityPath, + Component, EntityPath, }; fn main() { diff --git a/crates/re_arrow_store/examples/latest_components.rs b/crates/re_arrow_store/examples/latest_components.rs index f9f8a67b179d1..e6db104ae9eb6 100644 --- a/crates/re_arrow_store/examples/latest_components.rs +++ b/crates/re_arrow_store/examples/latest_components.rs @@ -10,8 +10,7 @@ use re_arrow_store::{test_bundle, DataStore, LatestAtQuery, TimeType, Timeline}; use re_log_types::{ component_types::{InstanceKey, Point2D, Rect2D}, datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - msg_bundle::Component, - EntityPath, + Component, EntityPath, }; fn main() { diff --git a/crates/re_arrow_store/examples/range_components.rs b/crates/re_arrow_store/examples/range_components.rs index 56b8f152fb7c8..d0fe7b8d732c4 100644 --- a/crates/re_arrow_store/examples/range_components.rs +++ b/crates/re_arrow_store/examples/range_components.rs @@ -9,8 +9,7 @@ use re_arrow_store::{polars_util, test_bundle, DataStore, RangeQuery, TimeRange} use re_log_types::{ component_types::{InstanceKey, Point2D, Rect2D}, datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - msg_bundle::Component as _, - EntityPath, TimeType, Timeline, + Component as _, EntityPath, TimeType, Timeline, }; fn main() { diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index ec5f131126270..1d7aa831c3baa 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -16,8 +16,7 @@ use re_log_types::{ build_frame_nr, build_log_time, build_some_colors, build_some_instances, build_some_point2d, }, external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::Component as _, - DataCell, Duration, EntityPath, MsgId, Time, TimeType, Timeline, + Component as _, DataCell, Duration, EntityPath, MsgId, Time, TimeType, Timeline, }; // --- diff --git a/crates/re_arrow_store/tests/data_store.rs b/crates/re_arrow_store/tests/data_store.rs index dc49147098334..673e1cf4e04fd 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -22,8 +22,8 @@ use re_log_types::{ build_some_point2d, build_some_rects, }, external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::{wrap_in_listarray, Component as _, MsgBundle}, - ComponentName, EntityPath, MsgId, TimeType, Timeline, + msg_bundle::{wrap_in_listarray, MsgBundle}, + Component as _, ComponentName, EntityPath, MsgId, TimeType, Timeline, }; // --- LatestComponentsAt --- diff --git a/crates/re_arrow_store/tests/internals.rs b/crates/re_arrow_store/tests/internals.rs index c7e1e5367c081..ef03e9ec373d3 100644 --- a/crates/re_arrow_store/tests/internals.rs +++ b/crates/re_arrow_store/tests/internals.rs @@ -8,8 +8,8 @@ use re_arrow_store::{DataStore, DataStoreConfig}; use re_log_types::{ component_types::InstanceKey, datagen::{build_frame_nr, build_some_instances}, - msg_bundle::{Component as _, MsgBundle}, - EntityPath, MsgId, TimePoint, + msg_bundle::MsgBundle, + Component as _, EntityPath, MsgId, TimePoint, }; // --- Internals --- diff --git a/crates/re_data_store/src/entity_properties.rs b/crates/re_data_store/src/entity_properties.rs index 7d82ed4beb560..14daebd49238d 100644 --- a/crates/re_data_store/src/entity_properties.rs +++ b/crates/re_data_store/src/entity_properties.rs @@ -1,7 +1,7 @@ use re_arrow_store::LatestAtQuery; use re_log_types::{ external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::DeserializableComponent, EntityPath, + DeserializableComponent, EntityPath, }; use crate::log_db::EntityDb; @@ -201,7 +201,7 @@ impl Default for ColorMapper { // ---------------------------------------------------------------------------- -/// Get the latest value for a given [`re_log_types::msg_bundle::Component`]. +/// Get the latest value for a given [`re_log_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. diff --git a/crates/re_data_store/src/log_db.rs b/crates/re_data_store/src/log_db.rs index fc30ad4963d58..c1552ebb99d90 100644 --- a/crates/re_data_store/src/log_db.rs +++ b/crates/re_data_store/src/log_db.rs @@ -3,10 +3,10 @@ use nohash_hasher::IntMap; use re_arrow_store::{DataStoreConfig, GarbageCollectionTarget, TimeInt}; use re_log_types::{ component_types::InstanceKey, - external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::{Component as _, MsgBundle}, - ArrowMsg, BeginRecordingMsg, ComponentPath, DataCell, EntityPath, EntityPathHash, - EntityPathOpMsg, LogMsg, MsgId, PathOp, RecordingId, RecordingInfo, TimePoint, Timeline, + external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, msg_bundle::MsgBundle, + ArrowMsg, BeginRecordingMsg, Component as _, ComponentPath, DataCell, EntityPath, + EntityPathHash, EntityPathOpMsg, LogMsg, MsgId, PathOp, RecordingId, RecordingInfo, TimePoint, + Timeline, }; use crate::{Error, TimesPerTimeline}; diff --git a/crates/re_log_types/src/component.rs b/crates/re_log_types/src/component.rs new file mode 100644 index 0000000000000..50cc987ac18be --- /dev/null +++ b/crates/re_log_types/src/component.rs @@ -0,0 +1,66 @@ +use arrow2::datatypes::Field; +use arrow2_convert::{ + deserialize::{ArrowArray, ArrowDeserialize}, + field::ArrowField, + serialize::ArrowSerialize, +}; + +use crate::ComponentName; + +// --- + +/// A type that can used as a Component of an Entity. +/// +/// Examples of components include positions and colors. +pub trait Component: ArrowField { + /// The name of the component. + fn name() -> ComponentName; + + /// Create a [`Field`] for this [`Component`]. + fn field() -> Field { + Field::new(Self::name().as_str(), Self::data_type(), false) + } +} + +// TODO(cmc): do a pass over these traits, this is incomprehensible... also why would a component +// ever not be (de)serializable? Do keep in mind the whole (component, datatype) story though. + +/// A [`Component`] that fulfils all the conditions required to be serialized as an Arrow payload. +pub trait SerializableComponent +where + Self: Component + ArrowSerialize + ArrowField + 'static, +{ +} + +impl SerializableComponent for C where + C: Component + ArrowSerialize + ArrowField + 'static +{ +} + +/// A [`Component`] that fulfils all the conditions required to be deserialized from an Arrow +/// payload. +/// +/// Note that due to the use of HRTBs in `arrow2_convert` traits, you will still need an extra HRTB +/// clause when marking a type as `DeserializableComponent`: +/// ```ignore +/// where +/// T: SerializableComponent, +/// for<'a> &'a T::ArrayType: IntoIterator, +/// ``` +pub trait DeserializableComponent +where + Self: Component, + Self: ArrowDeserialize + ArrowField + 'static, + Self::ArrayType: ArrowArray, + for<'b> &'b Self::ArrayType: IntoIterator, +{ +} + +impl DeserializableComponent for C +where + C: Component, + C: ArrowDeserialize + ArrowField + 'static, + C::ArrayType: ArrowArray, + for<'b> &'b C::ArrayType: IntoIterator, +{ +} diff --git a/crates/re_log_types/src/component_types/arrow.rs b/crates/re_log_types/src/component_types/arrow.rs index dfe304faafcfc..0110f9c493035 100644 --- a/crates/re_log_types/src/component_types/arrow.rs +++ b/crates/re_log_types/src/component_types/arrow.rs @@ -1,7 +1,7 @@ use super::Vec3D; use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A 3D Arrow /// diff --git a/crates/re_log_types/src/component_types/bbox.rs b/crates/re_log_types/src/component_types/bbox.rs index 2799752247450..d1cdb099aaa26 100644 --- a/crates/re_log_types/src/component_types/bbox.rs +++ b/crates/re_log_types/src/component_types/bbox.rs @@ -6,7 +6,7 @@ use arrow2_convert::{ serialize::ArrowSerialize, }; -use crate::msg_bundle::Component; +use crate::Component; /// A 3D bounding box represented by it's half-lengths /// diff --git a/crates/re_log_types/src/component_types/class_id.rs b/crates/re_log_types/src/component_types/class_id.rs index 16947fb110393..e12f9887e2c30 100644 --- a/crates/re_log_types/src/component_types/class_id.rs +++ b/crates/re_log_types/src/component_types/class_id.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A 16-bit ID representing a type of semantic class. /// diff --git a/crates/re_log_types/src/component_types/color.rs b/crates/re_log_types/src/component_types/color.rs index dda504f7396b8..471e81548b12b 100644 --- a/crates/re_log_types/src/component_types/color.rs +++ b/crates/re_log_types/src/component_types/color.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// An RGBA color tuple. /// diff --git a/crates/re_log_types/src/component_types/context.rs b/crates/re_log_types/src/component_types/context.rs index 109f6f9256c8d..da802530ef2a5 100644 --- a/crates/re_log_types/src/component_types/context.rs +++ b/crates/re_log_types/src/component_types/context.rs @@ -7,7 +7,7 @@ use arrow2_convert::{ use crate::{ component_types::{ClassId, KeypointId}, - msg_bundle::Component, + Component, }; use super::{ColorRGBA, Label}; diff --git a/crates/re_log_types/src/component_types/coordinates.rs b/crates/re_log_types/src/component_types/coordinates.rs index 58642833fdd61..9e11df9e5fa7e 100644 --- a/crates/re_log_types/src/component_types/coordinates.rs +++ b/crates/re_log_types/src/component_types/coordinates.rs @@ -5,7 +5,7 @@ use arrow2_convert::{ serialize::ArrowSerialize, }; -use crate::msg_bundle::Component; +use crate::Component; /// The six cardinal directions for 3D view-space and image-space. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/re_log_types/src/component_types/instance_key.rs b/crates/re_log_types/src/component_types/instance_key.rs index 6c846db45884a..b2a789f0e4ee8 100644 --- a/crates/re_log_types/src/component_types/instance_key.rs +++ b/crates/re_log_types/src/component_types/instance_key.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A number used to specify a specific instance in an entity. /// diff --git a/crates/re_log_types/src/component_types/keypoint_id.rs b/crates/re_log_types/src/component_types/keypoint_id.rs index 0d3b87b2a5cac..0381b81f44d4c 100644 --- a/crates/re_log_types/src/component_types/keypoint_id.rs +++ b/crates/re_log_types/src/component_types/keypoint_id.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A 16-bit ID representing a type of semantic keypoint within a class. /// diff --git a/crates/re_log_types/src/component_types/label.rs b/crates/re_log_types/src/component_types/label.rs index deb62f3677511..5ed51c3109820 100644 --- a/crates/re_log_types/src/component_types/label.rs +++ b/crates/re_log_types/src/component_types/label.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A String label component /// diff --git a/crates/re_log_types/src/component_types/linestrip.rs b/crates/re_log_types/src/component_types/linestrip.rs index 51036f5c26297..a77c18944c7be 100644 --- a/crates/re_log_types/src/component_types/linestrip.rs +++ b/crates/re_log_types/src/component_types/linestrip.rs @@ -7,7 +7,7 @@ use arrow2_convert::{ serialize::ArrowSerialize, }; -use crate::msg_bundle::Component; +use crate::Component; use super::Vec2D; use super::Vec3D; diff --git a/crates/re_log_types/src/component_types/mesh3d.rs b/crates/re_log_types/src/component_types/mesh3d.rs index d12567b176552..4eb9e2842ba3a 100644 --- a/crates/re_log_types/src/component_types/mesh3d.rs +++ b/crates/re_log_types/src/component_types/mesh3d.rs @@ -7,7 +7,7 @@ use arrow2_convert::deserialize::ArrowDeserialize; use arrow2_convert::field::ArrowField; use arrow2_convert::{serialize::ArrowSerialize, ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; use super::{FieldError, Vec4D}; diff --git a/crates/re_log_types/src/component_types/mod.rs b/crates/re_log_types/src/component_types/mod.rs index 13bcda42dc1aa..ba4d4f1125755 100644 --- a/crates/re_log_types/src/component_types/mod.rs +++ b/crates/re_log_types/src/component_types/mod.rs @@ -14,7 +14,7 @@ use arrow2_convert::{ }; use lazy_static::lazy_static; -use crate::msg_bundle::Component; +use crate::Component; mod arrow; mod arrow_convert_shims; diff --git a/crates/re_log_types/src/component_types/msg_id.rs b/crates/re_log_types/src/component_types/msg_id.rs index f5d28d8208dfd..9e28c81806923 100644 --- a/crates/re_log_types/src/component_types/msg_id.rs +++ b/crates/re_log_types/src/component_types/msg_id.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::{msg_bundle::Component, ComponentName}; +use crate::{Component, ComponentName}; /// A unique id per [`crate::LogMsg`]. /// diff --git a/crates/re_log_types/src/component_types/point.rs b/crates/re_log_types/src/component_types/point.rs index 3aba28f7ca421..764aa96b8b760 100644 --- a/crates/re_log_types/src/component_types/point.rs +++ b/crates/re_log_types/src/component_types/point.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; // TODO(cmc): Points should just be containers of Vecs. diff --git a/crates/re_log_types/src/component_types/quaternion.rs b/crates/re_log_types/src/component_types/quaternion.rs index e5822c9859ef5..11e9c21fd412d 100644 --- a/crates/re_log_types/src/component_types/quaternion.rs +++ b/crates/re_log_types/src/component_types/quaternion.rs @@ -6,7 +6,7 @@ use arrow2_convert::{ serialize::ArrowSerialize, }; -use crate::msg_bundle::Component; +use crate::Component; /// A Quaternion represented by 4 real numbers. /// diff --git a/crates/re_log_types/src/component_types/radius.rs b/crates/re_log_types/src/component_types/radius.rs index b60a168ce94e8..3049a2094d640 100644 --- a/crates/re_log_types/src/component_types/radius.rs +++ b/crates/re_log_types/src/component_types/radius.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A Radius component /// diff --git a/crates/re_log_types/src/component_types/rect.rs b/crates/re_log_types/src/component_types/rect.rs index 8b12d4e63f21f..a95fdf451f1a6 100644 --- a/crates/re_log_types/src/component_types/rect.rs +++ b/crates/re_log_types/src/component_types/rect.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; use super::Vec4D; diff --git a/crates/re_log_types/src/component_types/scalar.rs b/crates/re_log_types/src/component_types/scalar.rs index cfd1a3c522408..5b5612b82a987 100644 --- a/crates/re_log_types/src/component_types/scalar.rs +++ b/crates/re_log_types/src/component_types/scalar.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; // --- diff --git a/crates/re_log_types/src/component_types/size.rs b/crates/re_log_types/src/component_types/size.rs index 9e153ffca4eb7..a1d4bf808190c 100644 --- a/crates/re_log_types/src/component_types/size.rs +++ b/crates/re_log_types/src/component_types/size.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A 3D size, e.g. the size of a 3D box. // TODO(cmc): should just embed a Vec3D? diff --git a/crates/re_log_types/src/component_types/tensor.rs b/crates/re_log_types/src/component_types/tensor.rs index 4b678232d7d22..eef50e912ca17 100644 --- a/crates/re_log_types/src/component_types/tensor.rs +++ b/crates/re_log_types/src/component_types/tensor.rs @@ -4,7 +4,7 @@ use arrow2_convert::deserialize::ArrowDeserialize; use arrow2_convert::field::ArrowField; use arrow2_convert::{serialize::ArrowSerialize, ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; use crate::{TensorDataType, TensorElement}; use super::arrow_convert_shims::BinaryBuffer; diff --git a/crates/re_log_types/src/component_types/text_entry.rs b/crates/re_log_types/src/component_types/text_entry.rs index 7e74aeb5fbae4..2c562db38bd37 100644 --- a/crates/re_log_types/src/component_types/text_entry.rs +++ b/crates/re_log_types/src/component_types/text_entry.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; /// A text entry component, comprised of a text body and its log level. /// diff --git a/crates/re_log_types/src/component_types/transform.rs b/crates/re_log_types/src/component_types/transform.rs index 5b60468e596de..c57e70d1a9aa1 100644 --- a/crates/re_log_types/src/component_types/transform.rs +++ b/crates/re_log_types/src/component_types/transform.rs @@ -1,6 +1,6 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; -use crate::msg_bundle::Component; +use crate::Component; use super::{mat::Mat3x3, Quaternion, Vec2D, Vec3D}; diff --git a/crates/re_log_types/src/component_types/vec.rs b/crates/re_log_types/src/component_types/vec.rs index 6f328c6565b10..157c292a9bd38 100644 --- a/crates/re_log_types/src/component_types/vec.rs +++ b/crates/re_log_types/src/component_types/vec.rs @@ -1,7 +1,7 @@ use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize}; use super::FixedSizeArrayField; -use crate::msg_bundle::Component; +use crate::Component; /// Number of decimals shown for all vector display methods. const DISPLAY_PRECISION: usize = 3; diff --git a/crates/re_log_types/src/data_cell.rs b/crates/re_log_types/src/data_cell.rs index 35dc28da238f5..0101cbd642ac4 100644 --- a/crates/re_log_types/src/data_cell.rs +++ b/crates/re_log_types/src/data_cell.rs @@ -1,9 +1,8 @@ use arrow2_convert::deserialize::arrow_array_deserialize_iterator; use crate::{ - external::arrow2_convert::serialize::TryIntoArrow, - msg_bundle::{wrap_in_listarray, Component, DeserializableComponent, SerializableComponent}, - ComponentName, + external::arrow2_convert::serialize::TryIntoArrow, msg_bundle::wrap_in_listarray, Component, + ComponentName, DeserializableComponent, SerializableComponent, }; // --- diff --git a/crates/re_log_types/src/lib.rs b/crates/re_log_types/src/lib.rs index 72c8779e90927..d0b20f2391973 100644 --- a/crates/re_log_types/src/lib.rs +++ b/crates/re_log_types/src/lib.rs @@ -11,6 +11,7 @@ pub mod encoding; pub mod datagen; pub mod arrow_msg; +mod component; pub mod component_types; mod data; mod data_cell; @@ -35,6 +36,7 @@ pub mod external { } pub use self::arrow_msg::ArrowMsg; +pub use self::component::{Component, DeserializableComponent, SerializableComponent}; pub use self::component_types::context; pub use self::component_types::coordinates; pub use self::component_types::AnnotationContext; diff --git a/crates/re_log_types/src/msg_bundle.rs b/crates/re_log_types/src/msg_bundle.rs index 9c6b8a261cc45..673891fde3642 100644 --- a/crates/re_log_types/src/msg_bundle.rs +++ b/crates/re_log_types/src/msg_bundle.rs @@ -26,11 +26,7 @@ use arrow2::{ datatypes::{DataType, Field, Schema}, offset::Offsets, }; -use arrow2_convert::{ - deserialize::{ArrowArray, ArrowDeserialize}, - field::ArrowField, - serialize::{ArrowSerialize, TryIntoArrow}, -}; +use arrow2_convert::{field::ArrowField, serialize::TryIntoArrow}; use crate::{ parse_entity_path, ArrowMsg, ComponentName, DataCell, DataCellError, EntityPath, MsgId, @@ -84,64 +80,6 @@ const ENTITY_PATH_KEY: &str = "RERUN:entity_path"; const COL_COMPONENTS: &str = "components"; const COL_TIMELINES: &str = "timelines"; -// TODO(cmc): why is Component declared here? - -/// A type that can used as a Component of an Entity. -/// -/// Examples of components include positions and colors. -pub trait Component: ArrowField { - /// The name of the component. - fn name() -> ComponentName; - - /// Create a [`Field`] for this [`Component`]. - fn field() -> Field { - Field::new(Self::name().as_str(), Self::data_type(), false) - } -} - -// TODO(cmc): do a pass over these traits, this is incomprehensible... also why would a component -// ever not be (de)serializable? Do keep in mind the whole (component, datatype) story though. - -/// A [`Component`] that fulfils all the conditions required to be serialized as an Arrow payload. -pub trait SerializableComponent -where - Self: Component + ArrowSerialize + ArrowField + 'static, -{ -} - -impl SerializableComponent for C where - C: Component + ArrowSerialize + ArrowField + 'static -{ -} - -/// A [`Component`] that fulfils all the conditions required to be deserialized from an Arrow -/// payload. -/// -/// Note that due to the use of HRTBs in `arrow2_convert` traits, you will still need an extra HRTB -/// clause when marking a type as `DeserializableComponent`: -/// ```ignore -/// where -/// T: SerializableComponent, -/// for<'a> &'a T::ArrayType: IntoIterator, -/// ``` -pub trait DeserializableComponent -where - Self: Component, - Self: ArrowDeserialize + ArrowField + 'static, - Self::ArrayType: ArrowArray, - for<'b> &'b Self::ArrayType: IntoIterator, -{ -} - -impl DeserializableComponent for C -where - C: Component, - C: ArrowDeserialize + ArrowField + 'static, - C::ArrayType: ArrowArray, - for<'b> &'b C::ArrayType: IntoIterator, -{ -} - // --- /// A `MsgBundle` holds data necessary for composing a single log message. diff --git a/crates/re_query/benches/query_benchmark.rs b/crates/re_query/benches/query_benchmark.rs index d8ae38287e181..7ec74cddb8197 100644 --- a/crates/re_query/benches/query_benchmark.rs +++ b/crates/re_query/benches/query_benchmark.rs @@ -9,8 +9,8 @@ use re_log_types::{ component_types::{ColorRGBA, InstanceKey, Point2D, Vec3D}, datagen::{build_frame_nr, build_some_colors, build_some_point2d, build_some_vec3d}, entity_path, - msg_bundle::{try_build_msg_bundle1, try_build_msg_bundle2, Component, MsgBundle}, - EntityPath, Index, MsgId, TimeType, Timeline, + msg_bundle::{try_build_msg_bundle1, try_build_msg_bundle2, MsgBundle}, + Component, EntityPath, Index, MsgId, TimeType, Timeline, }; use re_query::query_entity_with_primary; diff --git a/crates/re_query/examples/range.rs b/crates/re_query/examples/range.rs index 027bf0df99b8f..365c32b8da0c7 100644 --- a/crates/re_query/examples/range.rs +++ b/crates/re_query/examples/range.rs @@ -8,8 +8,8 @@ use re_arrow_store::{DataStore, RangeQuery, TimeRange}; use re_log_types::{ component_types::{InstanceKey, Point2D, Rect2D}, datagen::{build_frame_nr, build_some_point2d, build_some_rects}, - msg_bundle::{try_build_msg_bundle1, Component as _}, - EntityPath, MsgId, TimeType, + msg_bundle::try_build_msg_bundle1, + Component as _, EntityPath, MsgId, TimeType, }; use re_query::range_entity_with_primary; diff --git a/crates/re_query/src/dataframe_util.rs b/crates/re_query/src/dataframe_util.rs index 3cd97967111a2..c71d48485eb5d 100644 --- a/crates/re_query/src/dataframe_util.rs +++ b/crates/re_query/src/dataframe_util.rs @@ -7,8 +7,8 @@ use polars_core::prelude::*; use re_arrow_store::ArrayExt; use re_log_types::{ component_types::InstanceKey, - external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::{Component, DeserializableComponent, SerializableComponent}, + external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, Component, + DeserializableComponent, SerializableComponent, }; use crate::{ diff --git a/crates/re_query/src/entity_view.rs b/crates/re_query/src/entity_view.rs index 4dd67ec962354..18687f58fe50c 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -8,8 +8,7 @@ use re_log_types::{ external::arrow2_convert::{ deserialize::arrow_array_deserialize_iterator, field::ArrowField, serialize::ArrowSerialize, }, - msg_bundle::{Component, DeserializableComponent, SerializableComponent}, - ComponentName, + Component, ComponentName, DeserializableComponent, SerializableComponent, }; use crate::QueryError; diff --git a/crates/re_query/src/query.rs b/crates/re_query/src/query.rs index 990ac52c0d813..0ae13f744a37a 100644 --- a/crates/re_query/src/query.rs +++ b/crates/re_query/src/query.rs @@ -1,16 +1,14 @@ use std::collections::BTreeMap; use re_arrow_store::{DataStore, LatestAtQuery}; -use re_log_types::{ - component_types::InstanceKey, msg_bundle::Component, ComponentName, EntityPath, -}; +use re_log_types::{component_types::InstanceKey, Component, ComponentName, EntityPath}; use crate::{ComponentWithInstances, EntityView, QueryError}; /// Retrieves a [`ComponentWithInstances`] from the [`DataStore`]. /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_log_types::{Timeline, component_types::Point2D, msg_bundle::Component}; +/// # use re_log_types::{Timeline, component_types::Point2D, Component}; /// # let store = re_query::__populate_example_store(); /// /// let ent_path = "point"; @@ -76,7 +74,7 @@ pub fn get_component_with_instances( /// /// ``` /// # use re_arrow_store::LatestAtQuery; -/// # use re_log_types::{Timeline, component_types::{Point2D, ColorRGBA}, msg_bundle::Component}; +/// # use re_log_types::{Timeline, component_types::{Point2D, ColorRGBA}, Component}; /// # let store = re_query::__populate_example_store(); /// /// let ent_path = "point"; @@ -179,7 +177,7 @@ pub fn __populate_example_store() -> DataStore { #[test] fn simple_get_component() { use re_arrow_store::LatestAtQuery; - use re_log_types::{component_types::Point2D, msg_bundle::Component as _, Timeline}; + use re_log_types::{component_types::Point2D, Component as _, Timeline}; let store = __populate_example_store(); @@ -216,8 +214,7 @@ fn simple_query_entity() { use re_arrow_store::LatestAtQuery; use re_log_types::{ component_types::{ColorRGBA, Point2D}, - msg_bundle::Component as _, - Timeline, + Component as _, Timeline, }; let store = __populate_example_store(); diff --git a/crates/re_query/src/range.rs b/crates/re_query/src/range.rs index 51615f64e3a8b..41d59a81c974f 100644 --- a/crates/re_query/src/range.rs +++ b/crates/re_query/src/range.rs @@ -1,6 +1,6 @@ use itertools::Itertools as _; use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery, TimeInt}; -use re_log_types::{msg_bundle::Component, ComponentName, EntityPath}; +use re_log_types::{Component, ComponentName, EntityPath}; use crate::{get_component_with_instances, ComponentWithInstances, EntityView}; diff --git a/crates/re_query/src/util.rs b/crates/re_query/src/util.rs index da6efbb0e19d7..45b61b78f0a01 100644 --- a/crates/re_query/src/util.rs +++ b/crates/re_query/src/util.rs @@ -1,6 +1,6 @@ use re_arrow_store::{DataStore, LatestAtQuery, RangeQuery, TimeInt, TimeRange, Timeline}; use re_data_store::ExtraQueryHistory; -use re_log_types::{msg_bundle::Component, ComponentName, EntityPath}; +use re_log_types::{Component, ComponentName, EntityPath}; use crate::{query_entity_with_primary, range_entity_with_primary, EntityView}; diff --git a/crates/re_query/src/visit.rs b/crates/re_query/src/visit.rs index 733debf3955b6..dccdb5050b51d 100644 --- a/crates/re_query/src/visit.rs +++ b/crates/re_query/src/visit.rs @@ -43,8 +43,7 @@ //! ``` use re_log_types::{ - component_types::InstanceKey, - msg_bundle::{Component, DeserializableComponent, SerializableComponent}, + component_types::InstanceKey, Component, DeserializableComponent, SerializableComponent, }; use crate::EntityView; diff --git a/crates/re_query/tests/query_tests.rs b/crates/re_query/tests/query_tests.rs index 1f65b8cf145d8..be8c1908d7a83 100644 --- a/crates/re_query/tests/query_tests.rs +++ b/crates/re_query/tests/query_tests.rs @@ -7,8 +7,7 @@ use re_log_types::{ datagen::build_frame_nr, msg_bundle::try_build_msg_bundle1, msg_bundle::try_build_msg_bundle2, - msg_bundle::Component, - MsgId, + Component, MsgId, }; use re_query::query_entity_with_primary; diff --git a/crates/re_query/tests/range_tests.rs b/crates/re_query/tests/range_tests.rs index 315f40735b5cb..8c007ae82a079 100644 --- a/crates/re_query/tests/range_tests.rs +++ b/crates/re_query/tests/range_tests.rs @@ -7,8 +7,7 @@ use re_log_types::{ datagen::build_frame_nr, msg_bundle::try_build_msg_bundle1, msg_bundle::try_build_msg_bundle2, - msg_bundle::Component, - EntityPath, MsgId, + Component, EntityPath, MsgId, }; use re_query::range_entity_with_primary; diff --git a/crates/re_sdk/src/lib.rs b/crates/re_sdk/src/lib.rs index c46d8a33fd543..75a4cbc17d858 100644 --- a/crates/re_sdk/src/lib.rs +++ b/crates/re_sdk/src/lib.rs @@ -31,8 +31,7 @@ pub use self::session::{Session, SessionBuilder}; pub use re_sdk_comms::default_server_addr; pub use re_log_types::{ - msg_bundle::{Component, SerializableComponent}, - ApplicationId, ComponentName, EntityPath, RecordingId, + ApplicationId, Component, ComponentName, EntityPath, RecordingId, SerializableComponent, }; // --------------- diff --git a/crates/re_viewer/src/ui/annotations.rs b/crates/re_viewer/src/ui/annotations.rs index 5ea85bb019da5..2e5ab34c83948 100644 --- a/crates/re_viewer/src/ui/annotations.rs +++ b/crates/re_viewer/src/ui/annotations.rs @@ -8,8 +8,7 @@ use re_data_store::EntityPath; use re_log_types::{ component_types::{ClassId, KeypointId}, context::{AnnotationInfo, ClassDescription}, - msg_bundle::Component, - AnnotationContext, MsgId, + AnnotationContext, Component, MsgId, }; use re_query::query_entity_with_primary; diff --git a/crates/re_viewer/src/ui/data_ui/component_ui_registry.rs b/crates/re_viewer/src/ui/data_ui/component_ui_registry.rs index fe1156c1fbbd4..dc5e885c6739b 100644 --- a/crates/re_viewer/src/ui/data_ui/component_ui_registry.rs +++ b/crates/re_viewer/src/ui/data_ui/component_ui_registry.rs @@ -2,10 +2,8 @@ use std::collections::BTreeMap; use re_arrow_store::LatestAtQuery; use re_log_types::{ - component_types::InstanceKey, - external::arrow2, - msg_bundle::{Component, DeserializableComponent}, - ComponentName, + component_types::InstanceKey, external::arrow2, Component, ComponentName, + DeserializableComponent, }; use re_query::ComponentWithInstances; diff --git a/crates/re_viewer/src/ui/space_view_heuristics.rs b/crates/re_viewer/src/ui/space_view_heuristics.rs index 1c1bbe02a739d..54507209e2a64 100644 --- a/crates/re_viewer/src/ui/space_view_heuristics.rs +++ b/crates/re_viewer/src/ui/space_view_heuristics.rs @@ -7,7 +7,7 @@ use re_arrow_store::{DataStore, LatestAtQuery, Timeline}; use re_data_store::{log_db::EntityDb, query_latest_single, ComponentName, EntityPath}; use re_log_types::{ component_types::{Tensor, TensorTrait}, - msg_bundle::Component, + Component, }; use crate::{ diff --git a/crates/re_viewer/src/ui/view_category.rs b/crates/re_viewer/src/ui/view_category.rs index 0d049ce195697..31318975aaecc 100644 --- a/crates/re_viewer/src/ui/view_category.rs +++ b/crates/re_viewer/src/ui/view_category.rs @@ -5,8 +5,7 @@ use re_log_types::{ Box3D, LineStrip2D, LineStrip3D, Point2D, Point3D, Rect2D, Scalar, Tensor, TensorTrait, TextEntry, }, - msg_bundle::Component, - Arrow3D, Mesh3D, Transform, + Arrow3D, Component, Mesh3D, Transform, }; use re_query::query_entity_with_primary; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/arrows3d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/arrows3d.rs index 1b03a037b212a..17c78d3a330c3 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/arrows3d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/arrows3d.rs @@ -2,8 +2,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{ColorRGBA, InstanceKey, Label, Radius}, - msg_bundle::Component, - Arrow3D, + Arrow3D, Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::{renderer::LineStripFlags, Size}; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes2d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes2d.rs index 8d6aa16569180..927f3c07f4d29 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes2d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes2d.rs @@ -2,7 +2,7 @@ use glam::Mat4; use re_data_store::{EntityPath, InstancePathHash}; use re_log_types::{ component_types::{ClassId, ColorRGBA, InstanceKey, Label, Radius, Rect2D}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, QueryError}; use re_renderer::Size; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes3d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes3d.rs index ceb9acdf38247..9a4cc28388b69 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes3d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/boxes3d.rs @@ -3,7 +3,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{Box3D, ClassId, ColorRGBA, InstanceKey, Label, Quaternion, Radius, Vec3D}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::Size; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/images.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/images.rs index f17f0a2d49f3b..37b0ffff07c78 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/images.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/images.rs @@ -7,8 +7,7 @@ use itertools::Itertools; use re_data_store::{query_latest_single, EntityPath, EntityProperties, InstancePathHash}; use re_log_types::{ component_types::{ColorRGBA, InstanceKey, Tensor, TensorData, TensorDataMeaning, TensorTrait}, - msg_bundle::Component, - Transform, + Component, Transform, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::{ diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines2d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines2d.rs index add122f7b5660..22acab4b0a5d8 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines2d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines2d.rs @@ -3,7 +3,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{ColorRGBA, InstanceKey, LineStrip2D, Radius}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::{renderer::LineStripFlags, Size}; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines3d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines3d.rs index efe214cc12ef8..a44d81079a7ee 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines3d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/lines3d.rs @@ -3,7 +3,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{ColorRGBA, InstanceKey, LineStrip3D, Radius}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::Size; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/meshes.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/meshes.rs index 842e8c7f94f6f..d00e5539f7b80 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/meshes.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/meshes.rs @@ -3,8 +3,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{ColorRGBA, InstanceKey}, - msg_bundle::Component, - Mesh3D, + Component, Mesh3D, }; use re_query::{query_primary_with_history, EntityView, QueryError}; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/mod.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/mod.rs index 3c5969ccee427..d4811ca9864d5 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/mod.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/mod.rs @@ -43,7 +43,7 @@ pub trait ScenePart { /// Computes the instance hash that should be used for picking (in turn for selecting/hover) /// /// Takes into account the currently the object properties, currently highlighted objects, and number of instances. -pub fn instance_path_hash_for_picking( +pub fn instance_path_hash_for_picking( ent_path: &EntityPath, instance_key: re_log_types::component_types::InstanceKey, entity_view: &re_query::EntityView, diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points2d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points2d.rs index e97a255f61924..d2e86093e0567 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points2d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points2d.rs @@ -3,7 +3,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties}; use re_log_types::{ component_types::{ClassId, ColorRGBA, InstanceKey, KeypointId, Label, Point2D, Radius}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::Size; diff --git a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs index 6072ad555b0c0..3303d8da0a43a 100644 --- a/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs +++ b/crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs @@ -6,7 +6,7 @@ use glam::Mat4; use re_data_store::{EntityPath, EntityProperties, InstancePathHash}; use re_log_types::{ component_types::{ClassId, ColorRGBA, InstanceKey, KeypointId, Label, Point3D, Radius}, - msg_bundle::Component, + Component, }; use re_query::{query_primary_with_history, EntityView, QueryError}; use re_renderer::Size; diff --git a/crates/re_viewer/src/ui/view_text/scene.rs b/crates/re_viewer/src/ui/view_text/scene.rs index 55d246be5d10b..498273cfa689a 100644 --- a/crates/re_viewer/src/ui/view_text/scene.rs +++ b/crates/re_viewer/src/ui/view_text/scene.rs @@ -2,8 +2,7 @@ use re_arrow_store::TimeRange; use re_data_store::EntityPath; use re_log_types::{ component_types::{self, InstanceKey}, - msg_bundle::Component, - MsgId, + Component, MsgId, }; use re_query::{range_entity_with_primary, QueryError}; diff --git a/crates/re_viewer/src/ui/view_time_series/scene.rs b/crates/re_viewer/src/ui/view_time_series/scene.rs index b530e9ccefc96..c063c5d5ab557 100644 --- a/crates/re_viewer/src/ui/view_time_series/scene.rs +++ b/crates/re_viewer/src/ui/view_time_series/scene.rs @@ -5,7 +5,7 @@ use crate::{ use re_arrow_store::TimeRange; use re_log_types::{ component_types::{self, InstanceKey}, - msg_bundle::Component, + Component, }; use re_query::{range_entity_with_primary, QueryError}; diff --git a/rerun_py/src/arrow.rs b/rerun_py/src/arrow.rs index b3e91b3c5b25d..433ab9b91c3e2 100644 --- a/rerun_py/src/arrow.rs +++ b/rerun_py/src/arrow.rs @@ -10,7 +10,7 @@ use pyo3::{ }; use re_log_types::{ component_types, - msg_bundle::{self, MsgBundle, MsgBundleError}, + msg_bundle::{MsgBundle, MsgBundleError}, DataCell, EntityPath, LogMsg, MsgId, TimePoint, }; @@ -44,9 +44,9 @@ fn array_to_rust(arrow_array: &PyAny, name: Option<&str>) -> PyResult<(Box::name() { + if name == ::name() { field.data_type = ::data_type(); - } else if name == ::name() { + } else if name == ::name() { field.data_type = ::data_type(); } }