Skip to content

Commit

Permalink
adapt everything to the brand new world
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Sep 26, 2023
1 parent 90c0c9d commit e9596e4
Show file tree
Hide file tree
Showing 54 changed files with 549 additions and 696 deletions.
49 changes: 2 additions & 47 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_arrow_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ polars-ops = { workspace = true, optional = true, features = [


[dev-dependencies]
re_components = { workspace = true, features = ["arrow_datagen"] }
re_types = { workspace = true, features = ["datagen"] }

anyhow.workspace = true
criterion = "0.5"
Expand Down
3 changes: 2 additions & 1 deletion crates/re_arrow_store/benches/arrow2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use std::sync::Arc;
use arrow2::array::{Array, PrimitiveArray, StructArray, UnionArray};
use criterion::{criterion_group, Criterion};
use itertools::Itertools;
use re_components::datagen::{build_some_instances, build_some_positions2d};

use re_log_types::{DataCell, SizeBytes as _};
use re_types::datagen::{build_some_instances, build_some_positions2d};
use re_types::{
components::{InstanceKey, Position2D},
testing::{build_some_large_structs, LargeStruct},
Expand Down
6 changes: 4 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,10 @@ use re_arrow_store::{
DataStore, DataStoreConfig, GarbageCollectionOptions, GarbageCollectionTarget, LatestAtQuery,
RangeQuery, TimeInt, TimeRange,
};
use re_components::datagen::{build_frame_nr, build_some_instances};
use re_log_types::{DataCell, DataRow, DataTable, EntityPath, RowId, TableId, TimeType, Timeline};
use re_log_types::{
build_frame_nr, DataCell, DataRow, DataTable, EntityPath, RowId, TableId, TimeType, Timeline,
};
use re_types::datagen::build_some_instances;
use re_types::{
components::InstanceKey,
testing::{build_some_large_structs, LargeStruct},
Expand Down
7 changes: 2 additions & 5 deletions crates/re_arrow_store/examples/dump_dataframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
//! ```

use re_arrow_store::{test_row, DataStore};
use re_components::datagen::{
build_frame_nr, build_log_time, build_some_instances, build_some_instances_from,
build_some_positions2d,
};
use re_log_types::{EntityPath, Time};
use re_log_types::{build_frame_nr, build_log_time, EntityPath, Time};
use re_types::datagen::{build_some_instances, build_some_instances_from, build_some_positions2d};
use re_types::{components::InstanceKey, testing::build_some_large_structs, Loggable};

// ---
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/examples/latest_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use re_arrow_store::polars_util::latest_component;
use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline};
use re_components::datagen::{build_frame_nr, build_some_positions2d};
use re_log_types::EntityPath;
use re_log_types::{build_frame_nr, EntityPath};
use re_types::datagen::build_some_positions2d;
use re_types::{
components::{InstanceKey, Position2D},
testing::{build_some_large_structs, LargeStruct},
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/examples/latest_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use polars_core::prelude::*;

use re_arrow_store::polars_util::latest_components;
use re_arrow_store::{test_row, DataStore, LatestAtQuery, TimeType, Timeline};
use re_components::datagen::{build_frame_nr, build_some_positions2d};
use re_log_types::EntityPath;
use re_log_types::{build_frame_nr, EntityPath};
use re_types::datagen::build_some_positions2d;
use re_types::{
components::{InstanceKey, Position2D},
testing::{build_some_large_structs, LargeStruct},
Expand Down
4 changes: 2 additions & 2 deletions crates/re_arrow_store/examples/range_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use polars_core::prelude::JoinType;
use re_arrow_store::{polars_util, test_row, DataStore, RangeQuery, TimeRange};
use re_components::datagen::{build_frame_nr, build_some_positions2d};
use re_log_types::{EntityPath, TimeType, Timeline};
use re_log_types::{build_frame_nr, EntityPath, TimeType, Timeline};
use re_types::datagen::build_some_positions2d;
use re_types::{
components::{InstanceKey, Position2D},
testing::{build_some_large_structs, LargeStruct},
Expand Down
89 changes: 23 additions & 66 deletions crates/re_arrow_store/src/arrow_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,82 +224,39 @@ impl ArrayExt for dyn Array {

#[test]
fn test_clean_for_polars_nomodify() {
use re_components::datagen::build_some_colors;
use re_log_types::DataCell;
use re_types::datagen::build_some_colors;

// Colors don't need polars cleaning
let cell: DataCell = build_some_colors(5).try_into().unwrap();
let cleaned = cell.as_arrow_ref().clean_for_polars();
assert_eq!(cell.as_arrow_ref(), &*cleaned);
}

#[cfg(test)]
mod tests {
use arrow2::datatypes::{DataType, Field, UnionMode};
use arrow2_convert::{ArrowDeserialize, ArrowField, ArrowSerialize};
use re_components::FixedSizeArrayField;
use re_log_types::DataCell;

use crate::ArrayExt;

#[derive(
Copy, Clone, Debug, Default, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize,
)]
#[arrow_field(transparent)]
pub struct Vec3D(#[arrow_field(type = "FixedSizeArrayField<f32,3>")] pub [f32; 3]);

#[derive(Clone, Copy, Debug, PartialEq, ArrowField, ArrowSerialize, ArrowDeserialize)]
#[arrow_field(type = "dense")]
enum TestComponentWithUnionAndFixedSizeList {
Bool(bool),
Vec3D(Vec3D),
}

re_log_types::component_legacy_shim!(TestComponentWithUnionAndFixedSizeList);
crate::polars_util::dataframe_from_cells(&[Some(cell)]).unwrap();
}

impl re_log_types::LegacyComponent for TestComponentWithUnionAndFixedSizeList {
fn legacy_name() -> re_log_types::ComponentName {
"test_component_with_union_and_fixed_size_list".into()
}
}
#[test]
fn test_clean_for_polars_modify() {
use std::f32::consts::PI;

#[test]
fn test_clean_for_polars_modify() {
// Pick a type with both Unions and FixedSizeLists
let elements = vec![TestComponentWithUnionAndFixedSizeList::Bool(false)];
use re_log_types::DataCell;
use re_types::components::Transform3D;
use re_types::datatypes::{
Angle, RotationAxisAngle, Scale3D, TranslationAndMat3x3, TranslationRotationScale3D,
};

let cell: DataCell = elements.try_into().unwrap();
assert_eq!(
*cell.datatype(),
DataType::Union(
vec![
Field::new("Bool", DataType::Boolean, false),
Field::new(
"Vec3D",
DataType::FixedSizeList(
Box::new(Field::new("item", DataType::Float32, false)),
3
),
false
)
],
None,
UnionMode::Dense
)
);
let cell = DataCell::try_from_native([
Transform3D::new(TranslationAndMat3x3::translation([1.0, 0.0, 0.0])), //
Transform3D::new(TranslationRotationScale3D {
rotation: Some(RotationAxisAngle::new([0.0, 0.0, 1.0], Angle::Radians(PI / 4.)).into()),
scale: Some(Scale3D::from(2.0)),
..Default::default()
}),
])
.unwrap();

let cleaned = cell.as_arrow_ref().clean_for_polars();
let cleaned = cell.as_arrow_ref().clean_for_polars();
assert_ne!(cell.as_arrow_ref(), &*cleaned);

assert_eq!(
*cleaned.data_type(),
DataType::Struct(vec![
Field::new("Bool", DataType::Boolean, false),
Field::new(
"Vec3D",
DataType::List(Box::new(Field::new("item", DataType::Float32, false))),
false
)
],)
);
}
crate::polars_util::dataframe_from_cells(&[Some(cell)]).unwrap();
}
6 changes: 3 additions & 3 deletions crates/re_arrow_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl DataStore {
/// ```
#[test]
fn datastore_internal_repr() {
use re_components::datagen::data_table_example;
use re_log_types::DataTable;
use re_types::{components::InstanceKey, Loggable as _};

let mut store = DataStore::new(
Expand All @@ -347,11 +347,11 @@ fn datastore_internal_repr() {
},
);

let timeless = data_table_example(true);
let timeless = DataTable::example(true);
eprintln!("{timeless}");
store.insert_table(&timeless).unwrap();

let temporal = data_table_example(false);
let temporal = DataTable::example(false);
eprintln!("{temporal}");
store.insert_table(&temporal).unwrap();

Expand Down
Loading

0 comments on commit e9596e4

Please sign in to comment.