Skip to content

Commit 6c63359

Browse files
committed
propagate changes
1 parent 9f17fd8 commit 6c63359

File tree

7 files changed

+32
-29
lines changed

7 files changed

+32
-29
lines changed

crates/store/re_chunk_store/src/events.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ mod tests {
266266
.with_component_batch(row_id1, timepoint1.clone(), &MyIndex::from_iter(0..10))
267267
.build()?;
268268

269-
view.on_events(&[store.insert_chunk(&Arc::new(chunk1))?.unwrap()]);
269+
view.on_events(&store.insert_chunk(&Arc::new(chunk1))?);
270270

271271
similar_asserts::assert_eq!(
272272
GlobalCounts::new(
@@ -311,7 +311,7 @@ mod tests {
311311
.build()?
312312
};
313313

314-
view.on_events(&[store.insert_chunk(&Arc::new(chunk2))?.unwrap()]);
314+
view.on_events(&store.insert_chunk(&Arc::new(chunk2))?);
315315

316316
similar_asserts::assert_eq!(
317317
GlobalCounts::new(
@@ -360,7 +360,7 @@ mod tests {
360360
.build()?
361361
};
362362

363-
view.on_events(&[store.insert_chunk(&Arc::new(chunk3))?.unwrap()]);
363+
view.on_events(&store.insert_chunk(&Arc::new(chunk3))?);
364364

365365
similar_asserts::assert_eq!(
366366
GlobalCounts::new(

crates/store/re_entity_db/src/entity_db.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use std::sync::Arc;
22

3-
use itertools::Itertools;
43
use nohash_hasher::IntMap;
54
use parking_lot::Mutex;
65

@@ -71,7 +70,11 @@ pub struct EntityDb {
7170

7271
impl EntityDb {
7372
pub fn new(store_id: StoreId) -> Self {
74-
let data_store = ChunkStore::new(store_id.clone(), ChunkStoreConfig::default());
73+
Self::with_store_config(store_id, ChunkStoreConfig::from_env().unwrap_or_default())
74+
}
75+
76+
pub fn with_store_config(store_id: StoreId, store_config: ChunkStoreConfig) -> Self {
77+
let data_store = ChunkStore::new(store_id.clone(), store_config);
7578
let query_caches = re_query::Caches::new(&data_store);
7679

7780
Self {
@@ -347,23 +350,23 @@ impl EntityDb {
347350
}
348351

349352
pub fn add_chunk(&mut self, chunk: &Arc<Chunk>) -> Result<(), Error> {
350-
let store_event = self.data_store.insert_chunk(chunk)?;
353+
let store_events = self.data_store.insert_chunk(chunk)?;
351354

352355
self.register_entity_path(chunk.entity_path());
353356

354357
if self.latest_row_id < chunk.row_id_range().map(|(_, row_id_max)| row_id_max) {
355358
self.latest_row_id = chunk.row_id_range().map(|(_, row_id_max)| row_id_max);
356359
}
357360

358-
if let Some(store_event) = store_event {
361+
{
359362
// Update our internal views by notifying them of resulting [`ChunkStoreEvent`]s.
360-
let original_store_events = &[store_event];
361-
self.times_per_timeline.on_events(original_store_events);
362-
self.query_caches.on_events(original_store_events);
363-
self.tree.on_store_additions(original_store_events);
363+
self.times_per_timeline.on_events(&store_events);
364+
self.query_caches.on_events(&store_events);
365+
self.tree.on_store_additions(&store_events);
366+
self.tree.on_store_deletions(&store_events);
364367

365368
// We inform the stats last, since it measures e2e latency.
366-
self.stats.on_events(original_store_events);
369+
self.stats.on_events(&store_events);
367370
}
368371

369372
Ok(())
@@ -435,8 +438,7 @@ impl EntityDb {
435438
times_per_timeline.on_events(store_events);
436439
query_caches.on_events(store_events);
437440

438-
let store_events = store_events.iter().collect_vec();
439-
tree.on_store_deletions(&store_events);
441+
tree.on_store_deletions(store_events);
440442
}
441443

442444
/// Key used for sorting recordings in the UI.

crates/store/re_entity_db/src/entity_tree.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,9 @@ impl EntityTree {
238238

239239
/// Updates the [`EntityTree`] by applying a batch of [`ChunkStoreEvent`]s.
240240
///
241-
/// Only reacts to additions (`event.kind == StoreDiffKind::Addition`).
241+
/// Only reacts to deletions (`event.kind == StoreDiffKind::Deletion`).
242242
pub fn on_store_additions(&mut self, events: &[ChunkStoreEvent]) {
243243
re_tracing::profile_function!();
244-
245244
for event in events
246245
.iter()
247246
.filter(|e| e.kind == ChunkStoreDiffKind::Addition)
@@ -297,7 +296,7 @@ impl EntityTree {
297296
/// Updates the [`EntityTree`] by applying a batch of [`ChunkStoreEvent`]s.
298297
///
299298
/// Only reacts to deletions (`event.kind == StoreDiffKind::Deletion`).
300-
pub fn on_store_deletions(&mut self, store_events: &[&ChunkStoreEvent]) {
299+
pub fn on_store_deletions(&mut self, store_events: &[ChunkStoreEvent]) {
301300
re_tracing::profile_function!();
302301

303302
let Self {
@@ -310,8 +309,9 @@ impl EntityTree {
310309
// Only keep events relevant to this branch of the tree.
311310
let subtree_events = store_events
312311
.iter()
313-
.filter(|e| e.diff.chunk.entity_path().starts_with(path))
314-
.copied() // NOTE: not actually copying, just removing the superfluous ref layer
312+
.filter(|e| e.kind == ChunkStoreDiffKind::Deletion)
313+
.filter(|&e| e.diff.chunk.entity_path().starts_with(path))
314+
.cloned()
315315
.collect_vec();
316316

317317
{
@@ -341,7 +341,7 @@ impl EntityTree {
341341

342342
{
343343
re_tracing::profile_scope!("subtree");
344-
for &event in &subtree_events {
344+
for event in &subtree_events {
345345
subtree.on_event(event);
346346
}
347347
}

crates/store/re_entity_db/src/time_histogram_per_timeline.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,13 @@ impl TimeHistogramPerTimeline {
100100
});
101101
} else {
102102
for &(timeline, times) in times_per_timeline {
103-
let histogram = self.times.entry(timeline).or_default();
104-
for &time in times {
105-
histogram.decrement(time, n);
106-
}
107-
if histogram.is_empty() {
108-
self.times.remove(&timeline);
103+
if let Some(histo) = self.times.get_mut(&timeline) {
104+
for &time in times {
105+
histo.decrement(time, n);
106+
}
107+
if histo.is_empty() {
108+
self.times.remove(&timeline);
109+
}
109110
}
110111
}
111112
}

crates/store/re_query/benches/latest_at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ fn insert_chunks<'a>(msgs: impl Iterator<Item = &'a Arc<Chunk>>) -> (Caches, Chu
254254
let mut caches = Caches::new(&store);
255255

256256
msgs.for_each(|chunk| {
257-
caches.on_events(&[store.insert_chunk(chunk).unwrap().unwrap()]);
257+
caches.on_events(&store.insert_chunk(chunk).unwrap());
258258
});
259259

260260
(caches, store)

crates/store/re_query/tests/latest_at.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ fn static_invalidation() {
545545
// ---
546546

547547
fn insert_and_react(store: &mut ChunkStore, caches: &mut Caches, chunk: &Arc<Chunk>) {
548-
caches.on_events(&[store.insert_chunk(chunk).unwrap().unwrap()]);
548+
caches.on_events(&store.insert_chunk(chunk).unwrap());
549549
}
550550

551551
fn query_and_compare(

crates/store/re_query/tests/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ fn concurrent_multitenant_edge_case2() {
10171017
// // ---
10181018

10191019
fn insert_and_react(store: &mut ChunkStore, caches: &mut Caches, chunk: &Arc<Chunk>) {
1020-
caches.on_events(&[store.insert_chunk(chunk).unwrap().unwrap()]);
1020+
caches.on_events(&store.insert_chunk(chunk).unwrap());
10211021
}
10221022

10231023
fn query_and_compare(

0 commit comments

Comments
 (0)