Skip to content

Commit

Permalink
get rid of superfluous TimePoint::timeless -- we already have default()
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Mar 15, 2024
1 parent 2a95903 commit 8fd761d
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 53 deletions.
2 changes: 1 addition & 1 deletion crates/re_data_source/src/data_loader/loader_archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl DataLoader for ArchetypeLoader {

let entity_path = EntityPath::from_file_path(&filepath);

let mut timepoint = TimePoint::timeless();
let mut timepoint = TimePoint::default();
// TODO(cmc): log these once heuristics (I think?) are fixed
if false {
if let Ok(metadata) = filepath.metadata() {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_source/src/data_loader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl DataLoaderSettings {
}

if let Some(timepoint) = timepoint {
if timepoint.is_timeless() {
if timepoint.is_static() {
args.push("--timeless".to_owned());
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/benches/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ fn timeless_logs(c: &mut Criterion) {
time_budget: std::time::Duration::MAX,
};

let mut timegen = |_| TimePoint::timeless();
let mut timegen = |_| TimePoint::default();

let mut datagen = |i: usize| {
Box::new(re_types::archetypes::TextLog::new(i.to_string())) as Box<dyn AsComponents>
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/src/store_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ mod tests {
);

let row_id3 = RowId::new();
let timepoint3 = TimePoint::timeless();
let timepoint3 = TimePoint::default();
let row3 = {
let num_instances = 6;
let colors = vec![MyColor::from(0x00DD00FF); num_instances];
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/src/store_gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl DataStore {

// TODO(jleibs): This is a worst-case removal-order. Would be nice to collect all the rows
// first and then remove them in one pass.
if timepoint.is_timeless() && gc_timeless {
if timepoint.is_static() && gc_timeless {
for table in timeless_tables.values_mut() {
// let deleted_comps = deleted.timeless.entry(ent_path.clone()_hash).or_default();
let (removed, num_bytes_removed) =
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/src/store_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ mod tests {
let colors = vec![MyColor::from(0x00DD00FF); num_instances];
DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
"entity_b".into(),
[
&InstanceKey::from_iter(0..num_instances as _) as _,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/src/store_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl DataStore {

let insert_id = self.config.store_insert_ids.then_some(self.insert_id);

if timepoint.is_timeless() {
if timepoint.is_static() {
let index = self
.timeless_tables
.entry(ent_path_hash)
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_store/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ macro_rules! test_row {
::re_log_types::DataRow::from_cells1_sized(
::re_log_types::RowId::new(),
$entity.clone(),
::re_log_types::TimePoint::timeless(),
::re_log_types::TimePoint::default(),
$n,
$c0,
)
Expand Down
12 changes: 6 additions & 6 deletions crates/re_data_store/tests/correctness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ fn row_id_ordering_semantics() -> anyhow::Result<()> {

let row = DataRow::from_component_batches(
row_id2,
TimePoint::timeless(),
TimePoint::default(),
entity_path.clone(),
[&[point1] as _],
)?;
store.insert_row(&row)?;

let row = DataRow::from_component_batches(
row_id1,
TimePoint::timeless(),
TimePoint::default(),
entity_path.clone(),
[&[point2] as _],
)?;
Expand Down Expand Up @@ -480,7 +480,7 @@ fn gc_metadata_size() -> anyhow::Result<()> {
for _ in 0..3 {
let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
"xxx".into(),
[&[point] as _],
)?;
Expand Down Expand Up @@ -546,7 +546,7 @@ fn entity_min_time_correct_impl(store: &mut DataStore) -> anyhow::Result<()> {

let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless()
TimePoint::default()
.with(timeline_log_time, now)
.with(timeline_frame_nr, 42),
ent_path.clone(),
Expand Down Expand Up @@ -576,7 +576,7 @@ fn entity_min_time_correct_impl(store: &mut DataStore) -> anyhow::Result<()> {
// insert row in the future, these shouldn't be visible
let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless()
TimePoint::default()
.with(timeline_log_time, now_plus_one)
.with(timeline_frame_nr, 54),
ent_path.clone(),
Expand Down Expand Up @@ -605,7 +605,7 @@ fn entity_min_time_correct_impl(store: &mut DataStore) -> anyhow::Result<()> {
// insert row in the past, these should be visible
let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless()
TimePoint::default()
.with(timeline_log_time, now_minus_one)
.with(timeline_frame_nr, 32),
ent_path.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/re_entity_db/src/time_histogram_per_timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl TimeHistogramPerTimeline {
}

pub fn remove(&mut self, timepoint: &TimePoint, n: u32) {
if timepoint.is_timeless() {
if timepoint.is_static() {
self.num_timeless_messages = self
.num_timeless_messages
.checked_sub(n as u64)
Expand Down
2 changes: 1 addition & 1 deletion crates/re_entity_db/tests/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ fn clear_and_gc() -> anyhow::Result<()> {

let mut db = EntityDb::new(StoreId::random(re_log_types::StoreKind::Recording));

let timepoint = TimePoint::timeless();
let timepoint = TimePoint::default();
let entity_path: EntityPath = "space_view".into();

// Insert a component, then clear it, then GC.
Expand Down
2 changes: 1 addition & 1 deletion crates/re_entity_db/tests/time_histograms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ fn time_histograms() -> anyhow::Result<()> {
let colors = vec![MyColor::from(0x00DD00FF); num_instances];
DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
"entity".into(),
[
&InstanceKey::from_iter(0..num_instances as _) as _,
Expand Down
4 changes: 2 additions & 2 deletions crates/re_log_types/src/data_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl DataTable {
/// and returns the corresponding [`TimePoint`].
#[inline]
pub fn timepoint_max(&self) -> TimePoint {
let mut timepoint = TimePoint::timeless();
let mut timepoint = TimePoint::default();
for (timeline, col_time) in &self.col_timelines {
let time = col_time
.iter()
Expand Down Expand Up @@ -1329,7 +1329,7 @@ impl DataTable {

let mut tick = 0i64;
let mut timepoint = |frame_nr: i64| {
let mut tp = TimePoint::timeless();
let mut tp = TimePoint::default();
if !timeless {
tp.insert(Timeline::log_time(), Time::now());
tp.insert(Timeline::log_tick(), tick);
Expand Down
14 changes: 4 additions & 10 deletions crates/re_log_types/src/time_point/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ pub use timeline::{Timeline, TimelineName};
///
/// It can be represented by [`Time`], a sequence index, or a mix of several things.
///
/// If this is empty, the data is _timeless_.
/// Timeless data will show up on all timelines, past and future,
/// and will hit all time queries. In other words, it is always there.
/// If a [`TimePoint`] is empty ([`TimePoint::default`]), the data will be considered _static_.
/// Static data has no time associated with it, exists on all timelines, and unconditionally shadows
/// any temporal data of the same type.
#[derive(Clone, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct TimePoint(BTreeMap<Timeline, TimeInt>);
Expand All @@ -32,12 +32,6 @@ impl From<BTreeMap<Timeline, TimeInt>> for TimePoint {
}

impl TimePoint {
/// Logging to this time means the data will show up in all timelines, past and future.
#[inline]
pub fn timeless() -> Self {
Self::default()
}

#[inline]
pub fn get(&self, timeline: &Timeline) -> Option<&TimeInt> {
self.0.get(timeline)
Expand All @@ -61,7 +55,7 @@ impl TimePoint {
}

#[inline]
pub fn is_timeless(&self) -> bool {
pub fn is_static(&self) -> bool {
self.0.is_empty()
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_query/tests/archetype_query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn timeless_query() {
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path,
TimePoint::timeless(),
TimePoint::default(),
1,
(color_instances, colors),
)
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query/tests/archetype_range_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ fn timeless_range() {
let row = DataRow::from_cells1_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
2,
&positions,
)
Expand All @@ -255,7 +255,7 @@ fn timeless_range() {
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
1,
(color_instances, colors),
)
Expand Down Expand Up @@ -303,7 +303,7 @@ fn timeless_range() {
let row = DataRow::from_cells1_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
2,
&positions,
)
Expand Down
8 changes: 4 additions & 4 deletions crates/re_query_cache/tests/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn timeless_query() {
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path,
TimePoint::timeless(),
TimePoint::default(),
1,
(color_instances, colors),
)
Expand Down Expand Up @@ -282,7 +282,7 @@ fn invalidation() {
query_and_compare(&caches, &store, &query, &ent_path.into());
};

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();
let frame_122 = build_frame_nr(122);
let frame_123 = build_frame_nr(123);
let frame_124 = build_frame_nr(124);
Expand Down Expand Up @@ -338,7 +338,7 @@ fn invalidation_of_future_optionals() {

let ent_path = "points";

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();
let frame2 = [build_frame_nr(2)];
let frame3 = [build_frame_nr(3)];

Expand Down Expand Up @@ -393,7 +393,7 @@ fn invalidation_timeless() {

let ent_path = "points";

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();

let query_time = [build_frame_nr(9999)];

Expand Down
12 changes: 6 additions & 6 deletions crates/re_query_cache/tests/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ fn timeless_range() {
let row = DataRow::from_cells1_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
2,
&positions,
)
Expand All @@ -151,7 +151,7 @@ fn timeless_range() {
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
1,
(color_instances, colors),
)
Expand Down Expand Up @@ -199,7 +199,7 @@ fn timeless_range() {
let row = DataRow::from_cells1_sized(
RowId::new(),
ent_path.clone(),
TimePoint::timeless(),
TimePoint::default(),
2,
&positions,
)
Expand Down Expand Up @@ -444,7 +444,7 @@ fn invalidation() {
query_and_compare(&caches, &store, &query, &ent_path.into());
};

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();
let frame_122 = build_frame_nr(122);
let frame_123 = build_frame_nr(123);
let frame_124 = build_frame_nr(124);
Expand Down Expand Up @@ -505,7 +505,7 @@ fn invalidation_of_future_optionals() {

let ent_path = "points";

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();
let frame2 = [build_frame_nr(2)];
let frame3 = [build_frame_nr(3)];

Expand Down Expand Up @@ -561,7 +561,7 @@ fn invalidation_timeless() {

let ent_path = "points";

let timeless = TimePoint::timeless();
let timeless = TimePoint::default();

let frame0 = [build_frame_nr(TimeInt::ZERO)];
let query = re_data_store::RangeQuery::new(frame0[0].0, TimeRange::EVERYTHING);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ impl RecordingStream {

// NOTE: The timepoint is irrelevant, the `RecordingStream` will overwrite it using its
// internal clock.
let timepoint = TimePoint::timeless();
let timepoint = TimePoint::default();

// TODO(#1893): unsplit splats once new data cells are in
let splatted = if splatted.is_empty() {
Expand Down
10 changes: 5 additions & 5 deletions crates/re_space_view/src/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ mod tests {
let row = DataRow::from_cells1_sized(
RowId::new(),
path.clone(),
TimePoint::timeless(),
TimePoint::default(),
1,
DataCell::from([component]),
)
Expand All @@ -505,8 +505,8 @@ mod tests {
"parent/skip/child1".into(),
"parent/skip/child2".into(),
] {
let row = DataRow::from_archetype(RowId::new(), TimePoint::timeless(), path, &points)
.unwrap();
let row =
DataRow::from_archetype(RowId::new(), TimePoint::default(), path, &points).unwrap();
recording.add_data_row(row).ok();
}

Expand Down Expand Up @@ -796,7 +796,7 @@ mod tests {
for entity_path in &entity_paths {
let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
entity_path.clone(),
[&[MyPoint::new(1.0, 2.0)] as _],
)
Expand Down Expand Up @@ -1005,7 +1005,7 @@ mod tests {
let mut add_to_blueprint = |path: &EntityPath, batch: &dyn ComponentBatch| {
let row = DataRow::from_component_batches(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
path.clone(),
std::iter::once(batch),
)
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/app_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn setup_welcome_screen_blueprint(welcome_screen_blueprint: &mut EntityDb) {
] {
let entity_path = EntityPath::from(panel_name);
// TODO(jleibs): Seq instead of timeless?
let timepoint = TimePoint::timeless();
let timepoint = TimePoint::default();

let component = PanelExpanded(is_expanded.into());

Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/ui/welcome_screen/welcome_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn open_quick_start(

let row = DataRow::from_archetype(
RowId::new(),
TimePoint::timeless(),
TimePoint::default(),
EntityPath::from(entry.entity_path),
&text_doc,
)?;
Expand Down
Loading

0 comments on commit 8fd761d

Please sign in to comment.