Skip to content

Commit

Permalink
Fix time-histogram removal book-keeping
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Jun 8, 2024
1 parent b8ea0a7 commit ea10be6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 3 additions & 6 deletions crates/re_entity_db/src/time_histogram_per_timeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,9 @@ impl TimeHistogramPerTimeline {
});
} else {
for (timeline, time_value) in timepoint.iter() {
let remaining_count = self
.times
.entry(*timeline)
.or_default()
.decrement(time_value.as_i64(), n);
if remaining_count == 0 {
let hist = self.times.entry(*timeline).or_default();
hist.decrement(time_value.as_i64(), n);
if hist.is_empty() {
self.times.remove(timeline);
}
}
Expand Down
10 changes: 9 additions & 1 deletion crates/re_entity_db/tests/time_histograms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,10 @@ fn assert_recursive_histogram<'a>(
let histo = db.time_histogram(timeline);

if let Some(expected) = expected_times {
if expected.is_empty() {
assert!(histo.is_none());
continue;
}
let histo = histo.unwrap();
let ranges = histo.range(i64::MIN.., 0).collect::<Vec<_>>();
let expected: Vec<_> = expected.to_vec();
Expand All @@ -692,9 +696,13 @@ fn assert_histogram_for_component<'a>(
.and_then(|tree| tree.time_histogram_for_component(timeline, component_name));

if let Some(expected) = expected_times {
let expected: Vec<_> = expected.to_vec();
if expected.is_empty() {
assert!(histo.is_none());
continue;
}
let histo = histo.unwrap();
let ranges = histo.range(i64::MIN.., 0).collect::<Vec<_>>();
let expected: Vec<_> = expected.to_vec();
similar_asserts::assert_eq!(expected, ranges);
} else {
assert!(histo.is_none());
Expand Down

0 comments on commit ea10be6

Please sign in to comment.