Skip to content

Commit

Permalink
migrate all arrow store internal testing to new Point2D
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jul 20, 2023
1 parent eb3472b commit 75e6b84
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 92 deletions.
11 changes: 8 additions & 3 deletions crates/re_arrow_store/benches/arrow2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use criterion::{criterion_group, Criterion};
use itertools::Itertools;
use re_components::{
datagen::{build_some_instances, build_some_point2d, build_some_rects},
LegacyPoint2D, Rect2D,
Point2D, Rect2D,
};
use re_log_types::{DataCell, SizeBytes as _};
use re_types::{components::InstanceKey, Component};
Expand Down Expand Up @@ -295,9 +295,14 @@ fn estimated_size_bytes(c: &mut Criterion) {
}

{
fn generate_points() -> Vec<Vec<LegacyPoint2D>> {
fn generate_points() -> Vec<Vec<Point2D>> {
(0..NUM_ROWS)
.map(|_| build_some_point2d(NUM_INSTANCES))
.map(|_| {
build_some_point2d(NUM_INSTANCES)
.into_iter()
.map(|p| Point2D::new(p.x, p.y))
.collect_vec()
})
.collect()
}

Expand Down
6 changes: 3 additions & 3 deletions crates/re_arrow_store/examples/latest_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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_point2d, build_some_rects},
LegacyPoint2D, Rect2D,
Point2D, Rect2D,
};
use re_log_types::EntityPath;
use re_types::{components::InstanceKey, Loggable};
Expand Down Expand Up @@ -45,8 +45,8 @@ fn main() {
&store,
&LatestAtQuery::new(timeline_frame_nr, 10.into()),
&ent_path,
LegacyPoint2D::name(),
Point2D::name(),
)
.unwrap();
println!("Query results from {:?}'s PoV:\n{df}", LegacyPoint2D::name());
println!("Query results from {:?}'s PoV:\n{df}", Point2D::name());
}
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 @@ -10,7 +10,7 @@ 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_point2d, build_some_rects},
LegacyPoint2D, Rect2D,
Point2D, Rect2D,
};
use re_log_types::EntityPath;
use re_types::{components::InstanceKey, Loggable};
Expand All @@ -31,7 +31,7 @@ fn main() {
&store,
&LatestAtQuery::new(timeline_frame_nr, 10.into()),
&ent_path,
&[LegacyPoint2D::name(), Rect2D::name()],
&[Point2D::name(), Rect2D::name()],
&JoinType::Outer,
)
.unwrap();
Expand Down
10 changes: 5 additions & 5 deletions crates/re_arrow_store/examples/range_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ 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_point2d, build_some_rects},
LegacyPoint2D, Rect2D,
Point2D, Rect2D,
};
use re_log_types::{EntityPath, TimeType, Timeline};
use re_types::{components::InstanceKey, Loggable};
Expand Down Expand Up @@ -56,7 +56,7 @@ fn main() {
&query,
&ent_path,
Rect2D::name(),
[InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()],
[InstanceKey::name(), Rect2D::name(), Point2D::name()],
&JoinType::Outer,
);
for (time, df) in dfs.map(Result::unwrap) {
Expand All @@ -77,8 +77,8 @@ fn main() {
&store,
&query,
&ent_path,
LegacyPoint2D::name(),
[InstanceKey::name(), Rect2D::name(), LegacyPoint2D::name()],
Point2D::name(),
[InstanceKey::name(), Rect2D::name(), Point2D::name()],
&JoinType::Outer,
);
for (time, df) in dfs.map(Result::unwrap) {
Expand All @@ -88,7 +88,7 @@ fn main() {
|| "<timeless>".into(),
|time| TimeType::Sequence.format(time)
),
LegacyPoint2D::name(),
Point2D::name(),
df,
);
}
Expand Down
14 changes: 5 additions & 9 deletions crates/re_arrow_store/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn range_join_across_single_row_impl(store: &mut DataStore) {
prelude::{DataFrame, JoinType},
series::Series,
};
use re_components::{ColorRGBA, LegacyPoint2D};
use re_components::{ColorRGBA, Point2D};

let ent_path = EntityPath::from("this/that");

Expand All @@ -232,16 +232,12 @@ fn range_join_across_single_row_impl(store: &mut DataStore) {
timeline_frame_nr,
re_arrow_store::TimeRange::new(i64::MIN.into(), i64::MAX.into()),
);
let components = [
InstanceKey::name(),
LegacyPoint2D::name(),
ColorRGBA::name(),
];
let components = [InstanceKey::name(), Point2D::name(), ColorRGBA::name()];
let dfs = re_arrow_store::polars_util::range_components(
store,
&query,
&ent_path,
LegacyPoint2D::name(),
Point2D::name(),
components,
&JoinType::Outer,
)
Expand All @@ -250,12 +246,12 @@ fn range_join_across_single_row_impl(store: &mut DataStore) {
let df_expected = {
let instances =
InstanceKey::to_arrow(vec![InstanceKey(0), InstanceKey(1), InstanceKey(2)], None);
let points = LegacyPoint2D::to_arrow(points, None);
let points = Point2D::to_arrow(points.into_iter().map(|p| Point2D::new(p.x, p.y)), None);
let colors = ColorRGBA::to_arrow(colors, None);

DataFrame::new(vec![
Series::try_from((InstanceKey::name().as_ref(), instances)).unwrap(),
Series::try_from((LegacyPoint2D::name().as_ref(), points)).unwrap(),
Series::try_from((Point2D::name().as_ref(), points)).unwrap(),
Series::try_from((ColorRGBA::name().as_ref(), colors)).unwrap(),
])
.unwrap()
Expand Down
Loading

0 comments on commit 75e6b84

Please sign in to comment.