Skip to content

Commit

Permalink
New data APIs 13: sunset legacy cache crate (#5994)
Browse files Browse the repository at this point in the history
`re_query_cache` is gone, `re_query_cache2` takes its place -- simple as
that.

---

Part of a PR series to completely revamp the data APIs in preparation
for the removal of instance keys and the introduction of promises:
- #5573
- #5574
- #5581
- #5605
- #5606
- #5633
- #5673
- #5679
- #5687
- #5755
- #5990
- #5992
- #5993 
- #5994
- #6035
- #6036
- #6037

Builds on top of the static data PR series:
- #5534
  • Loading branch information
teh-cmc authored Apr 26, 2024
1 parent 6d9e23c commit aa044bc
Show file tree
Hide file tree
Showing 106 changed files with 567 additions and 5,707 deletions.
32 changes: 0 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ re_log_types = { path = "crates/re_log_types", version = "=0.16.0-alpha.2", defa
re_memory = { path = "crates/re_memory", version = "=0.16.0-alpha.2", default-features = false }
re_query = { path = "crates/re_query", version = "=0.16.0-alpha.2", default-features = false }
re_query_cache = { path = "crates/re_query_cache", version = "=0.16.0-alpha.2", default-features = false }
re_query_cache2 = { path = "crates/re_query_cache2", version = "=0.16.0-alpha.2", default-features = false }
re_query2 = { path = "crates/re_query2", version = "=0.16.0-alpha.2", default-features = false }
re_renderer = { path = "crates/re_renderer", version = "=0.16.0-alpha.2", default-features = false }
re_sdk = { path = "crates/re_sdk", version = "=0.16.0-alpha.2", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use egui::NumExt;

use re_entity_db::{
external::re_query_cache2::CachedLatestAtComponentResults, EntityPath, InstancePath,
external::re_query_cache::CachedLatestAtComponentResults, EntityPath, InstancePath,
};
use re_types::ComponentName;
use re_ui::SyntaxHighlighting as _;
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl DataUi for ComponentPath {
));
} else {
let results =
db.query_caches2()
db.query_caches()
.latest_at(db.store(), query, entity_path, [*component_name]);
if let Some(results) = results.components.get(component_name) {
crate::EntityLatestAtResults {
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use re_data_store::LatestAtQuery;
use re_entity_db::{external::re_query_cache2::CachedLatestAtComponentResults, EntityDb};
use re_entity_db::{external::re_query_cache::CachedLatestAtComponentResults, EntityDb};
use re_log_types::{external::arrow2, EntityPath};
use re_types::external::arrow2::array::Utf8Array;
use re_viewer_context::{ComponentUiRegistry, UiVerbosity, ViewerContext};
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/editors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use egui::NumExt as _;
use re_data_store::LatestAtQuery;
use re_entity_db::{external::re_query_cache2::CachedLatestAtComponentResults, EntityDb};
use re_entity_db::{external::re_query_cache::CachedLatestAtComponentResults, EntityDb};
use re_log_types::EntityPath;
use re_types::{
components::{
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl DataUi for InstancePath {
.num_columns(2)
.show(ui, |ui| {
for component_name in normal_components {
let results = db.query_caches2().latest_at(
let results = db.query_caches().latest_at(
db.store(),
query,
entity_path,
Expand Down
3 changes: 1 addition & 2 deletions crates/re_entity_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ re_log_encoding = { workspace = true, features = ["decoder"] }
re_log_types.workspace = true
re_query.workspace = true
re_query2.workspace = true
re_query_cache.workspace = true
re_query_cache2 = { workspace = true, features = ["to_archetype"] }
re_query_cache = { workspace = true, features = ["to_archetype"] }
re_smart_channel.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true
Expand Down
42 changes: 14 additions & 28 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,11 @@ pub struct EntityDb {
/// Stores all components for all entities for all timelines.
data_store: DataStore,

/// Query caches for the data in [`Self::data_store`].
query_caches: re_query_cache::Caches,

/// The active promise resolver for this DB.
resolver: re_query2::PromiseResolver,

/// Query caches for the data in [`Self::data_store`].
query_caches2: re_query_cache2::Caches,
query_caches: re_query_cache::Caches,

stats: IngestionStatistics,
}
Expand All @@ -136,7 +133,6 @@ impl EntityDb {
DataStoreConfig::default(),
);
let query_caches = re_query_cache::Caches::new(&data_store);
let query_caches2 = re_query_cache2::Caches::new(&data_store);
Self {
data_source: None,
set_store_info: None,
Expand All @@ -146,9 +142,8 @@ impl EntityDb {
times_per_timeline: Default::default(),
tree: crate::EntityTree::root(),
data_store,
query_caches,
resolver: re_query2::PromiseResolver::default(),
query_caches2,
query_caches,
stats: IngestionStatistics::new(store_id),
}
}
Expand Down Expand Up @@ -201,11 +196,6 @@ impl EntityDb {
&self.query_caches
}

#[inline]
pub fn query_caches2(&self) -> &re_query_cache2::Caches {
&self.query_caches2
}

#[inline]
pub fn resolver(&self) -> &re_query2::PromiseResolver {
&self.resolver
Expand All @@ -219,21 +209,21 @@ impl EntityDb {
query: &re_data_store::LatestAtQuery,
) -> PromiseResult<Option<A>>
where
re_query_cache2::CachedLatestAtResults: re_query_cache2::ToArchetype<A>,
re_query_cache::CachedLatestAtResults: re_query_cache::ToArchetype<A>,
{
let results = self.query_caches2().latest_at(
let results = self.query_caches().latest_at(
self.store(),
query,
entity_path,
A::all_components().iter().copied(), // no generics!
);

use re_query_cache2::ToArchetype as _;
use re_query_cache::ToArchetype as _;
match results.to_archetype(self.resolver()).flatten() {
PromiseResult::Pending => PromiseResult::Pending,
PromiseResult::Error(err) => {
if let Some(err) = err.downcast_ref::<re_query_cache2::QueryError>() {
if matches!(err, re_query_cache2::QueryError::PrimaryNotFound(_)) {
if let Some(err) = err.downcast_ref::<re_query_cache::QueryError>() {
if matches!(err, re_query_cache::QueryError::PrimaryNotFound(_)) {
return PromiseResult::Ready(None);
}
}
Expand All @@ -248,8 +238,8 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<re_query_cache2::CachedLatestAtMonoResult<C>> {
self.query_caches2().latest_at_component::<C>(
) -> Option<re_query_cache::CachedLatestAtMonoResult<C>> {
self.query_caches().latest_at_component::<C>(
self.store(),
self.resolver(),
entity_path,
Expand All @@ -262,8 +252,8 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<re_query_cache2::CachedLatestAtMonoResult<C>> {
self.query_caches2().latest_at_component_quiet::<C>(
) -> Option<re_query_cache::CachedLatestAtMonoResult<C>> {
self.query_caches().latest_at_component_quiet::<C>(
self.store(),
self.resolver(),
entity_path,
Expand All @@ -276,8 +266,8 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<(EntityPath, re_query_cache2::CachedLatestAtMonoResult<C>)> {
self.query_caches2()
) -> Option<(EntityPath, re_query_cache::CachedLatestAtMonoResult<C>)> {
self.query_caches()
.latest_at_component_at_closest_ancestor::<C>(
self.store(),
self.resolver(),
Expand Down Expand Up @@ -477,7 +467,6 @@ impl EntityDb {
let original_store_events = &[store_event];
self.times_per_timeline.on_events(original_store_events);
self.query_caches.on_events(original_store_events);
self.query_caches2.on_events(original_store_events);
let clear_cascade = self.tree.on_store_additions(original_store_events);

// Second-pass: update the [`DataStore`] by applying the [`ClearCascade`].
Expand All @@ -487,7 +476,6 @@ impl EntityDb {
let new_store_events = self.on_clear_cascade(clear_cascade);
self.times_per_timeline.on_events(&new_store_events);
self.query_caches.on_events(&new_store_events);
self.query_caches2.on_events(&new_store_events);
let clear_cascade = self.tree.on_store_additions(&new_store_events);

// Clears don't affect `Clear` components themselves, therefore we cannot have recursive
Expand Down Expand Up @@ -643,15 +631,13 @@ impl EntityDb {
times_per_timeline,
tree,
data_store: _,
query_caches,
resolver: _,
query_caches2,
query_caches,
stats: _,
} = self;

times_per_timeline.on_events(store_events);
query_caches.on_events(store_events);
query_caches2.on_events(store_events);

let store_events = store_events.iter().collect_vec();
let compacted = CompactedStoreEvents::new(&store_events);
Expand Down
2 changes: 1 addition & 1 deletion crates/re_entity_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use editable_auto_value::EditableAutoValue;
pub mod external {
pub use re_data_store;
pub use re_query2;
pub use re_query_cache2;
pub use re_query_cache;
}

// ----------------------------------------------------------------------------
Expand Down
23 changes: 19 additions & 4 deletions crates/re_query_cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,37 @@ all-features = true


[features]
default = []
default = ["to_archetype"]

## Implements `ToArchetype<A>` for all builtin archetypes on `CachedLatestAtResults`.
to_archetype = ["dep:re_types", "dep:re_types_blueprint"]

[dependencies]
# Rerun dependencies:
re_data_store.workspace = true
re_error.workspace = true
re_format.workspace = true
re_log.workspace = true
re_log_types.workspace = true
re_query.workspace = true
re_query2.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true

# Rerun dependencies (optional):
re_types = { workspace = true, optional = true }
re_types_blueprint = { workspace = true, optional = true }

# External dependencies:
ahash.workspace = true
anyhow.workspace = true
backtrace.workspace = true
indent.workspace = true
indexmap.workspace = true
itertools.workspace = true
nohash-hasher.workspace = true
parking_lot.workspace = true
paste.workspace = true
seq-macro.workspace = true
static_assertions.workspace = true
web-time.workspace = true


Expand All @@ -56,11 +67,15 @@ similar-asserts.workspace = true
bench = false


[[example]]
name = "latest_at_archetype"
required-features = ["to_archetype"]


[[bench]]
name = "flat_vec_deque"
harness = false


[[bench]]
name = "latest_at"
harness = false
Loading

0 comments on commit aa044bc

Please sign in to comment.