Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 8, 2023
1 parent 08481a7 commit 5179c12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
35 changes: 10 additions & 25 deletions crates/re_arrow_store/src/store_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ impl DataStore {
&self,
time_filter: Option<(Timeline, TimeRange)>,
) -> impl Iterator<Item = DataTable> + '_ {
crate::profile_function!();

let timeless = self.dump_timeless_tables();
let temporal = if let Some(time_filter) = time_filter {
Either::Left(self.dump_temporal_tables_filtered(time_filter))
Expand All @@ -33,9 +31,9 @@ impl DataStore {
}

fn dump_timeless_tables(&self) -> impl Iterator<Item = DataTable> + '_ {
crate::profile_function!();

self.timeless_tables.values().map(|table| {
crate::profile_scope!("timeless_table");

let PersistentIndexedTable {
ent_path,
cluster_key: _,
Expand All @@ -46,7 +44,7 @@ impl DataStore {
} = table;

DataTable {
table_id: generate_table_id(),
table_id: TableId::random(),
col_row_id: col_row_id.clone(),
col_timelines: Default::default(),
col_entity_path: std::iter::repeat_with(|| ent_path.clone())
Expand All @@ -60,10 +58,10 @@ impl DataStore {

fn dump_temporal_tables(&self) -> impl Iterator<Item = DataTable> + '_ {
self.tables.values().flat_map(|table| {
crate::profile_function!();
crate::profile_scope!("temporal_table");

table.buckets.values().map(move |bucket| {
crate::profile_function!();
crate::profile_scope!("temporal_bucket");

bucket.sort_indices_if_needed();

Expand All @@ -86,7 +84,7 @@ impl DataStore {
debug_assert!(is_sorted);

DataTable {
table_id: generate_table_id(),
table_id: TableId::random(),
col_row_id: col_row_id.clone(),
col_timelines: [(*timeline, col_time.iter().copied().map(Some).collect())]
.into(),
Expand All @@ -107,14 +105,14 @@ impl DataStore {
self.tables
.values()
.filter_map(move |table| {
crate::profile_function!();
crate::profile_scope!("temporal_table_filtered");

if table.timeline != timeline_filter {
return None;
}

Some(table.buckets.values().filter_map(move |bucket| {
crate::profile_function!();
crate::profile_scope!("temporal_bucket_filtered");

bucket.sort_indices_if_needed();

Expand All @@ -136,7 +134,7 @@ impl DataStore {
} = &*inner.read();
debug_assert!(is_sorted);

if time_range.min > time_filter.max || time_range.max < time_filter.min {
if !time_range.intersects(time_filter) {
return None;
}

Expand Down Expand Up @@ -172,7 +170,7 @@ impl DataStore {
}

Some(DataTable {
table_id: generate_table_id(),
table_id: TableId::random(),
col_row_id,
col_timelines,
col_entity_path,
Expand All @@ -185,19 +183,6 @@ impl DataStore {
}
}

fn generate_table_id() -> TableId {
// NOTE: The `TableId` is only used for debugging purposes so this doesn't matter
// much... also we don't support saving to file on the web anyhow.
#[cfg(not(target_arch = "wasm32"))]
{
TableId::random()
}
#[cfg(target_arch = "wasm32")]
{
TableId::ZERO
}
}

fn filter_column<'a, T: 'a + Clone>(
col_time: &'a ErasedTimeVec,
column: impl Iterator<Item = &'a T> + 'a,
Expand Down
3 changes: 2 additions & 1 deletion crates/re_arrow_store/src/store_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ impl DataStore {
let values =
arrow2::array::UInt64Array::from_vec((0..num_instances as u64).collect_vec())
.boxed();
let cell = DataCell::from_arrow(InstanceKey::name(), values);
let mut cell = DataCell::from_arrow(InstanceKey::name(), values);
cell.compute_size_bytes();

self.cluster_cell_cache
.insert(num_instances, cell.clone() /* shallow */);
Expand Down
6 changes: 6 additions & 0 deletions crates/re_log_types/src/time_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ impl TimeRange {
self.min.as_i64().abs_diff(self.max.as_i64())
}

#[inline]
pub fn center(&self) -> TimeInt {
self.min + TimeInt::from((self.abs_length() / 2) as i64)
}
Expand All @@ -47,6 +48,11 @@ impl TimeRange {
self.min <= time && time <= self.max
}

#[inline]
pub fn intersects(&self, other: Self) -> bool {
self.min <= other.max && self.max >= other.min
}

#[inline]
pub fn union(&self, other: Self) -> Self {
Self {
Expand Down

0 comments on commit 5179c12

Please sign in to comment.