Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 8, 2024
1 parent fd73b60 commit ee4ede4
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions crates/re_query_cache2/benches/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ fn query_and_visit_points(
);

let points = results.get_required::<Position2D>().unwrap();
let colors = results.get_optional::<Color>();
let colors = results.get_or_empty::<Color>();

let points = points
.iter_dense::<Position2D>(&resolver)
Expand Down Expand Up @@ -348,7 +348,7 @@ fn query_and_visit_strings(
);

let points = results.get_required::<Position2D>().unwrap();
let colors = results.get_optional::<Text>();
let colors = results.get_or_empty::<Text>();

let points = points
.iter_dense::<Position2D>(&resolver)
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query_cache2/examples/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<MyPoint>()?;
let colors: &CachedLatestAtComponentResults = results.get_optional::<MyColor>();
let labels: &CachedLatestAtComponentResults = results.get_optional::<MyLabel>();
let colors: &CachedLatestAtComponentResults = results.get_or_empty::<MyColor>();
let labels: &CachedLatestAtComponentResults = results.get_or_empty::<MyLabel>();

// Then comes the time to resolve/convert and deserialize the data.
// These steps have to be done together for efficiency reasons.
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query_cache2/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl StoreSubscriber for Caches {

#[derive(Default, Debug)]
struct CompactedEvents {
timeless: HashSet<(EntityPath, ComponentName)>,
static_: HashSet<(EntityPath, ComponentName)>,
temporal: HashMap<CacheKey, BTreeSet<TimeInt>>,
}

Expand Down Expand Up @@ -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));
}
}
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query_cache2/src/latest_at/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -75,7 +75,7 @@ impl CachedLatestAtResults {
///
/// Returns empty results if the component is not present.
#[inline]
pub fn get_optional<C: Component>(&self) -> &CachedLatestAtComponentResults {
pub fn get_or_empty<C: Component>(&self) -> &CachedLatestAtComponentResults {
if let Some(component) = self.components.get(&C::name()) {
component
} else {
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query_cache2/tests/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ fn query_and_compare(
.flatten()
.unwrap();

let cached_colors = cached.get_optional::<MyColor>();
let cached_colors = cached.get_or_empty::<MyColor>();
let cached_color_data = cached_colors
.to_sparse::<MyColor>(&resolver)
.flatten()
Expand All @@ -511,7 +511,7 @@ fn query_and_compare(
.flatten()
.unwrap();

let expected_colors = expected.get_optional::<MyColor>();
let expected_colors = expected.get_or_empty::<MyColor>();
let expected_color_data = expected_colors
.to_sparse::<MyColor>(&resolver)
.flatten()
Expand Down

0 comments on commit ee4ede4

Please sign in to comment.