Skip to content

Commit

Permalink
propagate changes everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Mar 15, 2024
1 parent e624e05 commit e23c89a
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 77 deletions.
3 changes: 2 additions & 1 deletion crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ impl EntityDb {
}

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

/// Return the current `StoreGeneration`. This can be used to determine whether the
Expand Down
6 changes: 3 additions & 3 deletions crates/re_entity_db/src/entity_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub struct CompactedStoreEvents {
pub row_ids: HashSet<RowId>,

/// What time points were deleted for each entity+timeline+component?
pub timeful: IntMap<EntityPathHash, IntMap<Timeline, IntMap<ComponentName, Vec<TimeInt>>>>,
pub temporal: IntMap<EntityPathHash, IntMap<Timeline, IntMap<ComponentName, Vec<TimeInt>>>>,

/// For each entity+component, how many timeless entries were deleted?
pub timeless: IntMap<EntityPathHash, IntMap<ComponentName, u64>>,
Expand All @@ -158,7 +158,7 @@ impl CompactedStoreEvents {
pub fn new(store_events: &[&StoreEvent]) -> Self {
let mut this = CompactedStoreEvents {
row_ids: store_events.iter().map(|event| event.row_id).collect(),
timeful: Default::default(),
temporal: Default::default(),
timeless: Default::default(),
};

Expand All @@ -171,7 +171,7 @@ impl CompactedStoreEvents {
}
} else {
for &(timeline, time) in &event.times {
let per_timeline = this.timeful.entry(event.entity_path.hash()).or_default();
let per_timeline = this.temporal.entry(event.entity_path.hash()).or_default();
let per_component = per_timeline.entry(timeline).or_default();
for component_name in event.cells.keys() {
per_component.entry(*component_name).or_default().push(time);
Expand Down
58 changes: 1 addition & 57 deletions crates/re_entity_db/tests/clear.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use re_data_store::{DataStoreStats, LatestAtQuery};
use re_data_store::LatestAtQuery;
use re_entity_db::EntityDb;
use re_log_types::{
example_components::{MyColor, MyPoint},
Expand Down Expand Up @@ -383,59 +383,3 @@ fn clears() -> anyhow::Result<()> {

Ok(())
}

/// Test for GC behavior following clear. This functionality is expected by blueprints.
#[test]
fn clear_and_gc() -> anyhow::Result<()> {
re_log::setup_logging();

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

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

// Insert a component, then clear it, then GC.
{
// EntityTree is Empty when we start
assert_eq!(db.tree().num_children_and_fields(), 0);

let point = MyPoint::new(1.0, 2.0);

let row = DataRow::from_component_batches(
RowId::new(),
timepoint.clone(),
entity_path.clone(),
[&[point] as _],
)?;

db.add_data_row(row)?;

db.gc_everything_but_the_latest_row();

let stats = DataStoreStats::from_store(db.store());
assert_eq!(stats.timeless.num_rows, 1);

let clear = DataRow::from_component_batches(
RowId::new(),
timepoint.clone(),
entity_path.clone(),
Clear::recursive()
.as_component_batches()
.iter()
.map(|b| b.as_ref()),
)?;

db.add_data_row(clear)?;

db.gc_everything_but_the_latest_row();

// No rows should remain because the table should have been purged
let stats = DataStoreStats::from_store(db.store());
assert_eq!(stats.timeless.num_rows, 0);

// EntityTree should be empty again when we end since everything was GC'd
assert_eq!(db.tree().num_children_and_fields(), 0);
}

Ok(())
}
3 changes: 0 additions & 3 deletions crates/re_renderer_examples/picking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ impl framework::Example for Picking {
{
// Grab the middle pixel. usually we'd want to do something clever that snaps the closest object of interest.
let picked_id = picking_result.picked_id(picking_result.rect.extent / 2);
//let picked_position =
// picking_result.picked_world_position(picking_result.rect.extent / 2);
//dbg!(picked_position, picked_id);

self.mesh_is_hovered = false;
if picked_id == MESH_ID {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ macro_rules! impl_process_archetype {
&EntityPath,
&EntityProperties,
&SpatialSceneEntityContext<'_>,
(Option<TimeInt>, RowId),
(TimeInt, RowId),
&[InstanceKey],
$(&[$pov],)*
$(Option<&[Option<$comp>]>,)*
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 @@ -268,7 +268,7 @@ impl ViewTextFilters {
// ---

fn get_time_point(ctx: &ViewerContext<'_>, entry: &Entry) -> Option<TimePoint> {
if let Some((time_point, _)) = ctx.entity_db.store().get_msg_metadata(&entry.row_id) {
if let Some((time_point, _)) = ctx.entity_db.store().row_metadata(&entry.row_id) {
Some(time_point.clone())
} else {
re_log::warn_once!("Missing metadata for {:?}", entry.entity_path);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl VisualizerSystem for TextLogSystem {
self.entries.push(Entry {
row_id,
entity_path: data_result.entity_path.clone(),
time: time.map(|time| time.as_i64()),
time: (time.is_static()).then(|| time.as_i64()),
color: *color,
body: body.clone(),
level: level.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl LegacyTimeSeriesSystem {
store,
&query,
entity_path,
|_timeless, entry_range, (times, _, scalars, scatterings, colors, radii, labels)| {
|entry_range, (times, _, scalars, scatterings, colors, radii, labels)| {
let times = times.range(entry_range.clone()).map(|(time, _)| time.as_i64());

// Allocate all points.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ fn load_series(
store,
&query,
entity_path,
|_timeless, entry_range, (times, _, scalars, colors, stroke_widths, _, _)| {
|entry_range, (times, _, scalars, colors, stroke_widths, _, _)| {
let times = times.range(entry_range.clone()).map(|(time, _)| time.as_i64());
// Allocate all points.
points = times.map(|time| PlotPoint {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl SeriesPointSystem {
store,
&query,
entity_path,
|_timeless, entry_range, (times, _, scalars, colors, _, marker_sizes, markers)| {
|entry_range, (times, _, scalars, colors, _, marker_sizes, markers)| {
let times = times.range(entry_range.clone()).map(|(time, _)| time.as_i64());

// Allocate all points.
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewer/src/store_hub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ impl StoreHub {
};

let store_size_before =
entity_db.store().timeless_size_bytes() + entity_db.store().temporal_size_bytes();
entity_db.store().static_size_bytes() + entity_db.store().temporal_size_bytes();
entity_db.purge_fraction_of_ram(fraction_to_purge);
let store_size_after =
entity_db.store().timeless_size_bytes() + entity_db.store().temporal_size_bytes();
entity_db.store().static_size_bytes() + entity_db.store().temporal_size_bytes();

// No point keeping an empty recording around.
if entity_db.is_empty() {
Expand Down
6 changes: 3 additions & 3 deletions crates/re_viewer/src/ui/memory_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl MemoryPanel {
type_registry,
metadata_registry,
autogenerated,
timeless,
static_tables,
temporal,
temporal_buckets,
total,
Expand Down Expand Up @@ -301,9 +301,9 @@ impl MemoryPanel {
label_row_stats(ui, autogenerated);
ui.end_row();

ui.label("Timeless:");
ui.label("Static:");
ui.label("");
label_row_stats(ui, timeless);
label_row_stats(ui, static_tables);
ui.end_row();

ui.label("Temporal:");
Expand Down
3 changes: 1 addition & 2 deletions examples/rust/extend_viewer_ui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ fn entity_ui(
entity_path: &re_log_types::EntityPath,
) {
// Each entity can have many components (e.g. position, color, radius, …):
if let Some(mut components) = entity_db.store().all_components(&timeline, entity_path) {
components.sort(); // Make the order predicatable
if let Some(components) = entity_db.store().all_components(&timeline, entity_path) {
for component in components {
ui.collapsing(component.to_string(), |ui| {
component_ui(ui, entity_db, timeline, entity_path, component);
Expand Down

0 comments on commit e23c89a

Please sign in to comment.