diff --git a/crates/re_arrow_store/benches/data_store.rs b/crates/re_arrow_store/benches/data_store.rs index 1392ee6406978..8d7367d968bef 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 e6b16d46ecdfe..7282ef4e8b47a 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 8a4f9563cc0bf..bf35f99c3dcfc 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 dd00c46886be6..1b78b54471524 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 c25fe8db29cf2..95e9cc27a8631 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/src/store_write.rs b/crates/re_arrow_store/src/store_write.rs index 61ff4909693c4..e2e364dfaef0a 100644 --- a/crates/re_arrow_store/src/store_write.rs +++ b/crates/re_arrow_store/src/store_write.rs @@ -322,7 +322,7 @@ impl DataStore { // let cell = DataCell::from_component::(0..len as u64); // ...so we create it manually instead. - use re_log_types::msg_bundle::Component as _; + use re_log_types::Component as _; let values = arrow2::array::UInt64Array::from_vec((0..len as u64).collect_vec()).boxed(); let cell = DataCell::from_arrow(InstanceKey::name(), values); diff --git a/crates/re_arrow_store/tests/correctness.rs b/crates/re_arrow_store/tests/correctness.rs index 425f850c5b075..d73ed083bbb0b 100644 --- a/crates/re_arrow_store/tests/correctness.rs +++ b/crates/re_arrow_store/tests/correctness.rs @@ -15,8 +15,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 e4eb6f1598bc9..018482263d831 100644 --- a/crates/re_arrow_store/tests/data_store.rs +++ b/crates/re_arrow_store/tests/data_store.rs @@ -21,8 +21,8 @@ use re_log_types::{ build_some_point2d, build_some_rects, }, external::arrow2_convert::deserialize::arrow_array_deserialize_iterator, - msg_bundle::{Component as _, MsgBundle}, - ComponentName, DataCell, EntityPath, MsgId, TimeType, Timeline, + msg_bundle::MsgBundle, + Component as _, ComponentName, DataCell, EntityPath, MsgId, TimeType, Timeline, }; // --- LatestComponentsAt --- diff --git a/crates/re_arrow_store/tests/internals.rs b/crates/re_arrow_store/tests/internals.rs index a57438470e7e4..1307578781e46 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 0ecee09e2a958..5815f99db5921 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 3dd5932e175d5..83d3be38b96fe 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..cb3c03c69092a --- /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(#1694): 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 e599471d70156..6a0a1107140df 100644 --- a/crates/re_log_types/src/component_types/color.rs +++ b/crates/re_log_types/src/component_types/color.rs @@ -1,4 +1,4 @@ -use crate::msg_bundle::Component; +use crate::Component; /// An RGBA color tuple with unmultiplied/separate alpha, /// in sRGB gamma space with linear alpha. 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 9d0e8eb4eac56..4cddbad56db70 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 187fb0619ee33..89ad136b1486d 100644 --- a/crates/re_log_types/src/component_types/mesh3d.rs +++ b/crates/re_log_types/src/component_types/mesh3d.rs @@ -6,7 +6,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::arrow_convert_shims::BinaryBuffer; 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 502ab2b73c4ca..6e5c2c5e1eb13 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 74e189a42b91d..d95cbc64eea5b 100644 --- a/crates/re_log_types/src/data_cell.rs +++ b/crates/re_log_types/src/data_cell.rs @@ -1,9 +1,6 @@ use itertools::Itertools as _; -use crate::{ - msg_bundle::{Component, DeserializableComponent, SerializableComponent}, - ComponentName, -}; +use crate::{Component, ComponentName, DeserializableComponent, SerializableComponent}; // --- @@ -69,7 +66,7 @@ pub type DataCellResult = ::std::result::Result; /// # use arrow2_convert::field::ArrowField as _; /// # use itertools::Itertools as _; /// # -/// # use re_log_types::{DataCell, msg_bundle::Component as _}; +/// # use re_log_types::{DataCell, Component as _}; /// # use re_log_types::component_types::Point2D; /// # /// let points: &[Point2D] = &[ 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 9092a561b3457..ba382042a0c51 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(#1619): 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(#1694): 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 3dbeec55d6bd7..3d302faa3faaf 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 3f7599132ef8f..576813cec255d 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 0d4cb91136288..e0054b917d30e 100644 --- a/crates/re_query/src/entity_view.rs +++ b/crates/re_query/src/entity_view.rs @@ -7,8 +7,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 e1146609f6c8f..8731e8d202645 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 8fc96583602fc..45032d9ea2d38 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 f8b43dac0c155..e75bb22c67a51 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 ed3a29882b55e..d37be10dd0894 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 b92d662978044..e2a32004de947 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(); } }