Skip to content

Commit 41b2f35

Browse files
committed
Fixes and cleanups
1 parent 058b0df commit 41b2f35

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

crates/store/re_chunk/src/batcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,11 +914,11 @@ impl PendingRow {
914914

915915
row_ids.push(*row_id);
916916

917-
for (&timeline_name, cell) in row_timepoint {
917+
for (&timeline_name, &cell) in row_timepoint {
918918
let time_column = timelines.entry(timeline_name).or_insert_with(|| {
919919
PendingTimeColumn::new(Timeline::new(timeline_name, cell.typ()))
920920
});
921-
time_column.push(cell.as_time_int());
921+
time_column.push(cell.into());
922922
}
923923

924924
for (component_desc, arrays) in &mut components {

crates/store/re_data_loader/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ impl DataLoaderSettings {
145145
}
146146

147147
for (timeline, cell) in timepoint.iter() {
148+
// TODO(#8635): update this
148149
match cell.typ() {
149150
re_log_types::TimeType::Time => {
150151
args.extend([

crates/store/re_log_types/src/index/index_cell.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
use crate::{NonMinI64, TimeType};
2-
3-
use super::TimeInt;
1+
use crate::{NonMinI64, TimeInt, TimeType};
42

53
pub struct OutOfRange;
64

5+
/// An typed cell of an index, e.g. a point in time on some unknown timeline.
76
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
87
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
9-
/// An typed cell of an index, e.g. a point in time on some unknown timeline.
108
pub struct IndexCell {
119
pub typ: TimeType,
1210
pub value: NonMinI64,
@@ -49,15 +47,13 @@ impl IndexCell {
4947
self.typ
5048
}
5149

50+
/// Internal encoding.
51+
///
52+
/// Its meaning depends on the [`Self::typ`].
5253
#[inline]
5354
pub fn as_i64(&self) -> i64 {
5455
self.value.into()
5556
}
56-
57-
#[inline]
58-
pub fn as_time_int(&self) -> TimeInt {
59-
TimeInt::from(self.value)
60-
}
6157
}
6258

6359
impl re_byte_size::SizeBytes for IndexCell {
@@ -72,7 +68,29 @@ impl re_byte_size::SizeBytes for IndexCell {
7268
}
7369
}
7470

71+
impl From<IndexCell> for TimeInt {
72+
#[inline]
73+
fn from(cell: IndexCell) -> Self {
74+
Self::from(cell.value)
75+
}
76+
}
77+
78+
impl From<IndexCell> for NonMinI64 {
79+
#[inline]
80+
fn from(cell: IndexCell) -> Self {
81+
cell.value
82+
}
83+
}
84+
85+
impl From<IndexCell> for i64 {
86+
#[inline]
87+
fn from(cell: IndexCell) -> Self {
88+
cell.value.get()
89+
}
90+
}
91+
7592
impl From<std::time::Duration> for IndexCell {
93+
/// Saturating cast from [`std::time::Duration`].
7694
fn from(time: std::time::Duration) -> Self {
7795
Self::from_duration_nanos(NonMinI64::saturating_from_u128(time.as_nanos()))
7896
}
@@ -99,7 +117,7 @@ impl TryFrom<web_time::SystemTime> for IndexCell {
99117

100118
fn try_from(time: web_time::SystemTime) -> Result<Self, Self::Error> {
101119
let duration_since_epoch = time
102-
.duration_since(std::time::SystemTime::UNIX_EPOCH)
120+
.duration_since(web_time::SystemTime::UNIX_EPOCH)
103121
.map_err(|_ignored| OutOfRange)?;
104122
let nanos_since_epoch = duration_since_epoch.as_nanos();
105123
let nanos_since_epoch = i64::try_from(nanos_since_epoch).map_err(|_ignored| OutOfRange)?;

0 commit comments

Comments
 (0)