From ee4ede4da39b143658ded57a2f23898db5473668 Mon Sep 17 00:00:00 2001 From: Clement Rey Date: Mon, 8 Apr 2024 09:27:13 +0200 Subject: [PATCH] review --- crates/re_query_cache2/benches/latest_at.rs | 4 ++-- crates/re_query_cache2/examples/latest_at.rs | 6 +++--- crates/re_query_cache2/src/cache.rs | 6 +++--- crates/re_query_cache2/src/latest_at/results.rs | 4 ++-- crates/re_query_cache2/tests/latest_at.rs | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/re_query_cache2/benches/latest_at.rs b/crates/re_query_cache2/benches/latest_at.rs index c1a11cd413e20..f7c6082092248 100644 --- a/crates/re_query_cache2/benches/latest_at.rs +++ b/crates/re_query_cache2/benches/latest_at.rs @@ -297,7 +297,7 @@ fn query_and_visit_points( ); let points = results.get_required::().unwrap(); - let colors = results.get_optional::(); + let colors = results.get_or_empty::(); let points = points .iter_dense::(&resolver) @@ -348,7 +348,7 @@ fn query_and_visit_strings( ); let points = results.get_required::().unwrap(); - let colors = results.get_optional::(); + let colors = results.get_or_empty::(); let points = points .iter_dense::(&resolver) diff --git a/crates/re_query_cache2/examples/latest_at.rs b/crates/re_query_cache2/examples/latest_at.rs index 49fe471aa1d41..160154bf05893 100644 --- a/crates/re_query_cache2/examples/latest_at.rs +++ b/crates/re_query_cache2/examples/latest_at.rs @@ -37,13 +37,13 @@ fn main() -> anyhow::Result<()> { // Then, grab the results for each individual components. // * `get_required` returns an error if the component batch is missing - // * `get_optional` returns an empty set of results if the component if missing + // * `get_or_empty` returns an empty set of results if the component if missing // * `get` returns an option // // At this point we still don't know whether they are cached or not. That's the next step. let points: &CachedLatestAtComponentResults = results.get_required::()?; - let colors: &CachedLatestAtComponentResults = results.get_optional::(); - let labels: &CachedLatestAtComponentResults = results.get_optional::(); + let colors: &CachedLatestAtComponentResults = results.get_or_empty::(); + let labels: &CachedLatestAtComponentResults = results.get_or_empty::(); // Then comes the time to resolve/convert and deserialize the data. // These steps have to be done together for efficiency reasons. diff --git a/crates/re_query_cache2/src/cache.rs b/crates/re_query_cache2/src/cache.rs index 62fd738be918b..959707eca1c51 100644 --- a/crates/re_query_cache2/src/cache.rs +++ b/crates/re_query_cache2/src/cache.rs @@ -89,7 +89,7 @@ impl StoreSubscriber for Caches { #[derive(Default, Debug)] struct CompactedEvents { - timeless: HashSet<(EntityPath, ComponentName)>, + static_: HashSet<(EntityPath, ComponentName)>, temporal: HashMap>, } @@ -124,7 +124,7 @@ impl StoreSubscriber for Caches { if times.is_empty() { for component_name in cells.keys() { compacted - .timeless + .static_ .insert((entity_path.clone(), *component_name)); } } @@ -151,7 +151,7 @@ impl StoreSubscriber for Caches { // yet another layer of caching indirection. // But since this pretty much never happens in practice, let's not go there until we // have metrics showing that show we need to. - for (entity_path, component_name) in compacted.timeless { + for (entity_path, component_name) in compacted.static_ { for (key, cache) in caches.iter() { if key.entity_path == entity_path && key.component_name == component_name { cache.write().pending_invalidations.insert(TimeInt::STATIC); diff --git a/crates/re_query_cache2/src/latest_at/results.rs b/crates/re_query_cache2/src/latest_at/results.rs index 427b934ab4172..0028adcf41f57 100644 --- a/crates/re_query_cache2/src/latest_at/results.rs +++ b/crates/re_query_cache2/src/latest_at/results.rs @@ -19,7 +19,7 @@ use crate::{ /// The data is both deserialized and resolved/converted. /// /// Use [`CachedLatestAtResults::get`], [`CachedLatestAtResults::get_required`] and -/// [`CachedLatestAtResults::get_optional`] in order to access the results for each individual component. +/// [`CachedLatestAtResults::get_or_empty`] in order to access the results for each individual component. #[derive(Debug)] pub struct CachedLatestAtResults { /// The compound index of this query result. @@ -75,7 +75,7 @@ impl CachedLatestAtResults { /// /// Returns empty results if the component is not present. #[inline] - pub fn get_optional(&self) -> &CachedLatestAtComponentResults { + pub fn get_or_empty(&self) -> &CachedLatestAtComponentResults { if let Some(component) = self.components.get(&C::name()) { component } else { diff --git a/crates/re_query_cache2/tests/latest_at.rs b/crates/re_query_cache2/tests/latest_at.rs index 89d8e37a6c0de..b87b1bb02da61 100644 --- a/crates/re_query_cache2/tests/latest_at.rs +++ b/crates/re_query_cache2/tests/latest_at.rs @@ -492,7 +492,7 @@ fn query_and_compare( .flatten() .unwrap(); - let cached_colors = cached.get_optional::(); + let cached_colors = cached.get_or_empty::(); let cached_color_data = cached_colors .to_sparse::(&resolver) .flatten() @@ -511,7 +511,7 @@ fn query_and_compare( .flatten() .unwrap(); - let expected_colors = expected.get_optional::(); + let expected_colors = expected.get_or_empty::(); let expected_color_data = expected_colors .to_sparse::(&resolver) .flatten()