Skip to content

Commit

Permalink
self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 15, 2024
1 parent 0f8a9e1 commit 368ab68
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/re_query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn get_component_with_instances(
/// # let store = re_query::__populate_example_store();
///
/// let ent_path = "point";
/// let query = LatestAtQuery::n ew(Timeline::new_sequence("frame_nr"), 123.into());
/// let query = LatestAtQuery::new(Timeline::new_sequence("frame_nr"), 123.into());
///
/// let arch_view = re_query::query_archetype::<MyPoints>(
/// &store,
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query_cache/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ pub struct CachesPerArchetype {
/// time effectively behaves as a natural micro-batching mechanism.
pending_timeful_invalidation: Option<TimeInt>,

/// If `true`, the timeless data associated with this case has been asynchronously invalidated.
/// If `true`, the timeless data associated with this cache has been asynchronously invalidated.
///
/// The next time this cache gets queried, it must remove any entry matching this criteria.
/// If `true`, this cache must remove all of its timeless entries the next time it gets queried.
/// `false` indicates that there's no pending invalidation.
///
/// Invalidation is deferred to query time because it is far more efficient that way: the frame
Expand Down Expand Up @@ -194,7 +194,7 @@ impl StoreSubscriber for Caches {
} = event;

let StoreDiff {
kind: _, // Don't care: both additions and deletions invalid query results.
kind: _, // Don't care: both additions and deletions invalidate query results.
row_id: _,
times,
entity_path,
Expand Down
69 changes: 69 additions & 0 deletions crates/re_query_cache/tests/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ fn invalidation() {
//
// # Do third query here: LatestAt(+inf)
// # Expected: points=[[1,2,3]] colors=[0x0000FF]
//
// rr.set_time(3)
// rr.log_components("points", rr.components.Color(0x00FF00))
//
// # Do fourth query here: LatestAt(+inf)
// # Expected: points=[[1,2,3]] colors=[0x00FF00]
// ```
#[test]
fn invalidation_of_future_optionals() {
Expand Down Expand Up @@ -365,6 +371,69 @@ fn invalidation_of_future_optionals() {

let query = re_data_store::LatestAtQuery::new(query_time[0].0, query_time[0].1);
query_and_compare(&store, &query, &ent_path.into());

let color_instances = vec![InstanceKey::SPLAT];
let colors = vec![Color::from_rgb(0, 255, 0)];
let row =
DataRow::from_cells2_sized(RowId::new(), ent_path, frame3, 1, (color_instances, colors))
.unwrap();
store.insert_row(&row).unwrap();

let query = re_data_store::LatestAtQuery::new(query_time[0].0, query_time[0].1);
query_and_compare(&store, &query, &ent_path.into());
}

#[test]
fn invalidation_timeless() {
let mut store = DataStore::new(
re_log_types::StoreId::random(re_log_types::StoreKind::Recording),
InstanceKey::name(),
Default::default(),
);

let ent_path = "points";

let timeless = TimePoint::timeless();

let query_time = [build_frame_nr(9999.into())];

let positions = vec![Position2D::new(1.0, 2.0), Position2D::new(3.0, 4.0)];
let row =
DataRow::from_cells1_sized(RowId::new(), ent_path, timeless.clone(), 2, positions).unwrap();
store.insert_row(&row).unwrap();

let query = re_data_store::LatestAtQuery::new(query_time[0].0, query_time[0].1);
query_and_compare(&store, &query, &ent_path.into());

let color_instances = vec![InstanceKey::SPLAT];
let colors = vec![Color::from_rgb(255, 0, 0)];
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path,
timeless.clone(),
1,
(color_instances, colors),
)
.unwrap();
store.insert_row(&row).unwrap();

let query = re_data_store::LatestAtQuery::new(query_time[0].0, query_time[0].1);
query_and_compare(&store, &query, &ent_path.into());

let color_instances = vec![InstanceKey::SPLAT];
let colors = vec![Color::from_rgb(0, 0, 255)];
let row = DataRow::from_cells2_sized(
RowId::new(),
ent_path,
timeless,
1,
(color_instances, colors),
)
.unwrap();
store.insert_row(&row).unwrap();

let query = re_data_store::LatestAtQuery::new(query_time[0].0, query_time[0].1);
query_and_compare(&store, &query, &ent_path.into());
}

// ---
Expand Down

0 comments on commit 368ab68

Please sign in to comment.