Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Mar 23, 2023
1 parent c67eac9 commit 7ff1630
Show file tree
Hide file tree
Showing 65 changed files with 149 additions and 165 deletions.
4 changes: 2 additions & 2 deletions crates/re_arrow_store/benches/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

// ---
Expand Down
3 changes: 1 addition & 2 deletions crates/re_arrow_store/examples/dump_dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

// ---
Expand Down
3 changes: 1 addition & 2 deletions crates/re_arrow_store/examples/latest_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions crates/re_arrow_store/examples/latest_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions crates/re_arrow_store/examples/range_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions crates/re_arrow_store/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

// ---
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/tests/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/tests/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_store/src/entity_properties.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions crates/re_data_store/src/log_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
66 changes: 66 additions & 0 deletions crates/re_log_types/src/component.rs
Original file line number Diff line number Diff line change
@@ -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<ArrowFieldType = Self>
where
Self: Component + ArrowSerialize + ArrowField<Type = Self> + 'static,
{
}

impl<C> SerializableComponent for C where
C: Component + ArrowSerialize + ArrowField<Type = C> + '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<ArrowFieldType = Self>
where
Self: Component,
Self: ArrowDeserialize + ArrowField<Type = ArrowFieldType> + 'static,
Self::ArrayType: ArrowArray,
for<'b> &'b Self::ArrayType: IntoIterator,
{
}

impl<C> DeserializableComponent for C
where
C: Component,
C: ArrowDeserialize + ArrowField<Type = C> + 'static,
C::ArrayType: ArrowArray,
for<'b> &'b C::ArrayType: IntoIterator,
{
}
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/arrow.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Vec3D;
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

/// A 3D Arrow
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/bbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/class_id.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/color.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

/// An RGBA color tuple.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use arrow2_convert::{

use crate::{
component_types::{ClassId, KeypointId},
msg_bundle::Component,
Component,
};

use super::{ColorRGBA, Label};
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/coordinates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/instance_key.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/keypoint_id.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/label.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

/// A String label component
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/linestrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use arrow2_convert::{
serialize::ArrowSerialize,
};

use crate::msg_bundle::Component;
use crate::Component;

use super::Vec2D;
use super::Vec3D;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/mesh3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/msg_id.rs
Original file line number Diff line number Diff line change
@@ -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`].
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/point.rs
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/quaternion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use arrow2_convert::{
serialize::ArrowSerialize,
};

use crate::msg_bundle::Component;
use crate::Component;

/// A Quaternion represented by 4 real numbers.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/radius.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

/// A Radius component
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/rect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

use super::Vec4D;

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/scalar.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};

use crate::msg_bundle::Component;
use crate::Component;

// ---

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/size.rs
Original file line number Diff line number Diff line change
@@ -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?
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/text_entry.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/transform.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down
2 changes: 1 addition & 1 deletion crates/re_log_types/src/component_types/vec.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions crates/re_log_types/src/data_cell.rs
Original file line number Diff line number Diff line change
@@ -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,
};

// ---
Expand Down
Loading

0 comments on commit 7ff1630

Please sign in to comment.