Skip to content

Commit

Permalink
post-merge craziness
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 15, 2024
1 parent 5fb6abd commit a64f1c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions crates/re_query_cache/src/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ macro_rules! impl_query_archetype_latest_at {
f(data);
}


Ok(())
};

Expand Down Expand Up @@ -135,9 +136,10 @@ macro_rules! impl_query_archetype_latest_at {
re_log::trace!(query_time=?query.at, "cache hit (query time)");
return iter_results(false, &query_time_bucket_at_query_time.get().read());
}
entry @ std::collections::btree_map::Entry::Vacant(_) => entry,
entry => entry,
};


let arch_view = query_archetype::<A>(store, &query, entity_path)?;
let data_time = arch_view.data_time();

Expand All @@ -164,12 +166,15 @@ macro_rules! impl_query_archetype_latest_at {
}
}

let query_time_bucket_at_query_time = query_time_bucket_at_query_time.or_default();

// Slowest path: this is a complete cache miss.
if let Some(data_time) = data_time { // Reminder: `None` means timeless.
re_log::trace!(query_time=?query.at, ?data_time, "cache miss");

// BEWARE: Do _not_ move this out of this scope, or a bucket would be created
// even when taking the timeless path!
let query_time_bucket_at_query_time = query_time_bucket_at_query_time.or_default();

{
let mut query_time_bucket_at_query_time = query_time_bucket_at_query_time.write();
*total_size_bytes += upsert_results(data_time, &arch_view, &mut query_time_bucket_at_query_time)?;
Expand All @@ -188,6 +193,7 @@ macro_rules! impl_query_archetype_latest_at {
iter_results(true, &timeless_bucket)?;

*timeless = Some(timeless_bucket);

Ok(())
}
};
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query_cache/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ macro_rules! impl_query_archetype_range {
};

fn upsert_results<'a, A, $($pov,)+ $($comp,)*>(
arch_views: impl Iterator<Item = (Option<TimeInt>, re_query::ArchetypeView<A>)>,
arch_views: impl Iterator<Item = re_query::ArchetypeView<A>>,
bucket: &mut crate::CacheBucket,
) -> crate::Result<u64>
where
Expand All @@ -87,8 +87,8 @@ macro_rules! impl_query_archetype_range {
let mut added_entries = 0u64;
let mut added_size_bytes = 0u64;

for (data_time, arch_view) in arch_views {
let data_time = data_time.unwrap_or(TimeInt::MIN); // TODO(cmc): timeless
for arch_view in arch_views {
let data_time = arch_view.data_time().unwrap_or(TimeInt::MIN); // TODO(cmc): timeless

if bucket.contains_data_row(data_time, arch_view.primary_row_id()) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query_cache/tests/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ fn query_and_compare(store: &DataStore, query: &RangeQuery, ent_path: &EntityPat
let expected = re_query::range_archetype::<MyPoints, { MyPoints::NUM_COMPONENTS }>(
store, query, ent_path,
);
for (data_time, arch_view) in expected {
expected_data_times.push(data_time);
for arch_view in expected {
expected_data_times.push(arch_view.data_time());
expected_instance_keys.push(arch_view.iter_instance_keys().collect_vec());
expected_positions.push(
arch_view
Expand Down

0 comments on commit a64f1c3

Please sign in to comment.