Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 5, 2024
1 parent c89da2b commit 20d1082
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 24 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions crates/re_data_store/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,9 @@ pub struct StaticTable {
/// place.
pub cluster_key: ComponentName,

/// Keeps track of one and only one [`StaticCell`] per component.
///
/// Last-write-wins semantics apply, where ordering is defined by `RowId`.
pub cells: BTreeMap<ComponentName, StaticCell>,
}

Expand All @@ -570,7 +573,9 @@ impl StaticTable {

#[derive(Clone)]
pub struct StaticCell {
/// None if [`DataStoreConfig::store_insert_ids`] is `false`.
pub insert_id: Option<u64>,

pub row_id: RowId,
pub num_instances: NumInstances,
pub cell: DataCell,
Expand Down
3 changes: 1 addition & 2 deletions crates/re_data_store/src/store_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ impl std::fmt::Display for DataStore {
f.write_str(&indent::indent_all_by(
4,
format!(
"{} static tables, for a total of {} across {} total cells\n",
"{} static tables, for a total of {}\n",
static_tables.len(),
format_bytes(self.static_size_bytes() as _),
format_uint(self.num_static_cells())
),
))?;
f.write_str(&indent::indent_all_by(4, "static_tables: [\n"))?;
Expand Down
2 changes: 2 additions & 0 deletions crates/re_data_store/src/store_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ impl DataStore {
/// the specified [`Timeline`].
///
/// Static components are always included in the results.
///
/// Returns `None` if the entity doesn't exist at all on this `timeline`.
pub fn all_components(
&self,
timeline: &Timeline,
Expand Down
13 changes: 5 additions & 8 deletions crates/re_data_store/src/store_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl DataStoreStats {
let static_tables = {
re_tracing::profile_scope!("static data");
DataStoreRowStats {
num_rows: store.num_static_cells(),
num_rows: store.num_static_rows(),
num_bytes: store.static_size_bytes(),
}
};
Expand Down Expand Up @@ -190,14 +190,11 @@ impl SizeBytes for DataStore {
}

impl DataStore {
/// Returns the number of static cells stored across this entire store.
/// Returns the number of static rows stored across this entire store.
#[inline]
pub fn num_static_cells(&self) -> u64 {
re_tracing::profile_function!();
self.static_tables
.values()
.map(|static_table| static_table.cells.len() as u64)
.sum()
pub fn num_static_rows(&self) -> u64 {
// A static table only ever contains a single row.
self.static_tables.len() as _
}

/// Returns the size of the static data stored across this entire store.
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_store/tests/data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ fn protected_gc_clear_impl(store: &mut DataStore) {

// The 3 static cells should still be around.
let stats = DataStoreStats::from_store(store);
assert_eq!(stats.static_tables.num_rows, 2);
assert_eq!(stats.static_tables.num_rows, 1);

// Now erase points and GC again
let mut static_table = DataTable::from_rows(TableId::new(), [row4]);
Expand All @@ -856,5 +856,5 @@ fn protected_gc_clear_impl(store: &mut DataStore) {
});

let stats = DataStoreStats::from_store(store);
assert_eq!(stats.static_tables.num_rows, 2);
assert_eq!(stats.static_tables.num_rows, 1);
}
3 changes: 1 addition & 2 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ impl EntityDb {
}

pub fn num_rows(&self) -> usize {
(self.data_store.num_static_cells() > 0) as usize
+ self.data_store.num_temporal_rows() as usize
self.data_store.num_static_rows() as usize + self.data_store.num_temporal_rows() as usize
}

/// Return the current `StoreGeneration`. This can be used to determine whether the
Expand Down
4 changes: 2 additions & 2 deletions crates/re_log_types/src/time_point/time_int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl TimeInt {

/// Returns `i64::MIN` for [`Self::STATIC`].
#[inline]
pub fn as_i64(&self) -> i64 {
pub const fn as_i64(&self) -> i64 {
match self.0 {
Some(t) => t.get(),
None => i64::MIN,
Expand All @@ -121,7 +121,7 @@ impl TimeInt {

/// Returns `f64::MIN` for [`Self::STATIC`].
#[inline]
pub fn as_f64(&self) -> f64 {
pub const fn as_f64(&self) -> f64 {
match self.0 {
Some(t) => t.get() as _,
None => f64::MIN,
Expand Down
1 change: 1 addition & 0 deletions crates/re_query_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ itertools.workspace = true
parking_lot.workspace = true
paste.workspace = true
seq-macro.workspace = true
static_assertions.workspace = true
web-time.workspace = true


Expand Down
5 changes: 2 additions & 3 deletions crates/re_query_cache/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,8 @@ impl CacheBucket {
/// multiple times.
#[inline]
pub fn static_range(&self) -> Range<usize> {
let start_index = self
.data_times
.partition_point(|(data_time, _)| data_time < &TimeInt::STATIC);
static_assertions::const_assert_eq!(TimeInt::STATIC.as_i64(), i64::MIN);
let start_index = 0;
let end_index = self
.data_times
.partition_point(|(data_time, _)| data_time <= &TimeInt::STATIC);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_log/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl SpaceViewClass for TextSpaceView {
let time_cursor_moved = state.latest_time != time;
let scroll_to_row = time_cursor_moved.then(|| {
re_tracing::profile_scope!("search scroll time");
entries.partition_point(|te| te.time.unwrap_or(i64::MIN) < time)
entries.partition_point(|te| te.time.as_i64() < time)
});

state.latest_time = time;
Expand Down
7 changes: 3 additions & 4 deletions crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use re_data_store::TimeRange;
use re_entity_db::EntityPath;
use re_log_types::RowId;
use re_log_types::{RowId, TimeInt};
use re_types::{
archetypes::TextLog,
components::{Color, Text, TextLogLevel},
Expand All @@ -17,8 +17,7 @@ pub struct Entry {

pub entity_path: EntityPath,

/// `None` for timeless data.
pub time: Option<i64>,
pub time: TimeInt,

pub color: Option<Color>,

Expand Down Expand Up @@ -74,7 +73,7 @@ impl VisualizerSystem for TextLogSystem {
self.entries.push(Entry {
row_id,
entity_path: data_result.entity_path.clone(),
time: (time.is_static()).then(|| time.as_i64()),
time,
color: *color,
body: body.clone(),
level: level.clone(),
Expand Down

0 comments on commit 20d1082

Please sign in to comment.