Skip to content

Commit

Permalink
minimal TimeInt sanity pass (see #4832)
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 23, 2024
1 parent ea4d410 commit 600c6b3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 9 deletions.
3 changes: 2 additions & 1 deletion crates/re_data_store/src/store_format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use re_format::{format_bytes, format_number};
use re_log_types::TimeInt;
use re_types_core::SizeBytes as _;

use crate::{DataStore, IndexedBucket, IndexedTable, PersistentIndexedTable};
Expand Down Expand Up @@ -129,7 +130,7 @@ impl std::fmt::Display for IndexedBucket {

let time_range = {
let time_range = &self.inner.read().time_range;
if time_range.min.as_i64() != i64::MAX && time_range.max.as_i64() != i64::MIN {
if time_range.min != TimeInt::MAX && time_range.max != TimeInt::MIN {
format!(
" - {}: {}",
self.timeline.name(),
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_store/src/store_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl std::fmt::Debug for RangeQuery {
self.timeline.typ().format_utc(self.range.min),
self.timeline.typ().format_utc(self.range.max),
self.timeline.name(),
if self.range.min == TimeInt::MIN {
if self.range.min <= TimeInt::MIN {
"including"
} else {
"excluding"
Expand Down Expand Up @@ -494,7 +494,7 @@ impl DataStore {
.flatten()
.map(|(time, row_id, cells)| (Some(time), row_id, cells));

if query.range.min == TimeInt::MIN {
if query.range.min <= TimeInt::MIN {
let timeless = self
.timeless_tables
.get(&ent_path_hash)
Expand Down
16 changes: 13 additions & 3 deletions crates/re_data_store/src/store_sanity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use re_log_types::{DataCellColumn, NumInstances, RowId, TimeRange, VecDequeSortingExt as _};
use re_log_types::{
DataCellColumn, NumInstances, RowId, TimeInt, TimeRange, VecDequeSortingExt as _,
};
use re_types_core::{ComponentName, Loggable, SizeBytes as _};

use crate::{
Expand Down Expand Up @@ -179,8 +181,16 @@ impl IndexedBucket {
let mut times = col_time.clone();
times.sort();

let expected_min = times.front().copied().unwrap_or(i64::MAX).into();
let expected_max = times.back().copied().unwrap_or(i64::MIN).into();
let expected_min = times
.front()
.copied()
.unwrap_or(TimeInt::MAX.as_i64())
.into();
let expected_max = times
.back()
.copied()
.unwrap_or(TimeInt::MIN.as_i64())
.into();
let expected_time_range = TimeRange::new(expected_min, expected_max);

if expected_time_range != *time_range {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ fn range_join_across_single_row_impl(store: &mut DataStore) {
let timeline_frame_nr = Timeline::new("frame_nr", TimeType::Sequence);
let query = re_data_store::RangeQuery::new(
timeline_frame_nr,
re_data_store::TimeRange::new(i64::MIN.into(), i64::MAX.into()),
re_data_store::TimeRange::new(TimeInt::MIN, TimeInt::MAX),
);
let components = [InstanceKey::name(), Position2D::name(), Color::name()];
let dfs = re_data_store::polars_util::range_components(
Expand Down
1 change: 1 addition & 0 deletions crates/re_log_types/src/time_point/time_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl TimeInt {
// a bit of leeway.
pub const BEGINNING: Self = Self(i64::MIN / 2);

// TODO(#4832): `TimeInt::BEGINNING` vs. `TimeInt::MIN` vs. `Option<TimeInt>`…
pub const MIN: Self = Self(i64::MIN);
pub const MAX: Self = Self(i64::MAX);

Expand Down
1 change: 0 additions & 1 deletion crates/re_query_cache/src/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ macro_rules! impl_query_archetype_latest_at {
f(data);
}


Ok(())
};

Expand Down
3 changes: 2 additions & 1 deletion crates/re_space_view_time_series/src/visualizer_system.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use re_data_store::TimeRange;
use re_log_types::TimeInt;
use re_query_cache::QueryError;
use re_types::{
archetypes::TimeSeriesScalar,
Expand Down Expand Up @@ -152,7 +153,7 @@ impl TimeSeriesSystem {
visible_history.to(query.latest_at),
)
} else {
(i64::MIN.into(), i64::MAX.into())
(TimeInt::MIN, TimeInt::MAX)
};

let query =
Expand Down

0 comments on commit 600c6b3

Please sign in to comment.