Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New data APIs 14: port everything that used to be uncached #6035

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 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 crates/re_entity_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ re_log.workspace = true
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, features = ["to_archetype"] }
re_smart_channel.workspace = true
re_tracing.workspace = true
Expand Down
14 changes: 8 additions & 6 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use re_log_types::{
EntityPathHash, LogMsg, RowId, SetStoreInfo, StoreId, StoreInfo, StoreKind, TimePoint,
TimeRange, TimeRangeF, Timeline,
};
use re_query2::PromiseResult;
use re_query_cache::PromiseResult;
use re_types_core::{components::InstanceKey, Archetype, Loggable};

use crate::{ClearCascade, CompactedStoreEvents, Error, TimesPerTimeline};
Expand Down Expand Up @@ -117,7 +117,7 @@ pub struct EntityDb {
data_store: DataStore,

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

/// Query caches for the data in [`Self::data_store`].
query_caches: re_query_cache::Caches,
Expand All @@ -142,7 +142,7 @@ impl EntityDb {
times_per_timeline: Default::default(),
tree: crate::EntityTree::root(),
data_store,
resolver: re_query2::PromiseResolver::default(),
resolver: re_query_cache::PromiseResolver::default(),
query_caches,
stats: IngestionStatistics::new(store_id),
}
Expand Down Expand Up @@ -197,7 +197,7 @@ impl EntityDb {
}

#[inline]
pub fn resolver(&self) -> &re_query2::PromiseResolver {
pub fn resolver(&self) -> &re_query_cache::PromiseResolver {
&self.resolver
}

Expand All @@ -207,7 +207,7 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> PromiseResult<Option<A>>
) -> PromiseResult<Option<((re_log_types::TimeInt, RowId), A)>>
where
re_query_cache::CachedLatestAtResults: re_query_cache::ToArchetype<A>,
{
Expand All @@ -229,7 +229,9 @@ impl EntityDb {
}
PromiseResult::Error(err)
}
PromiseResult::Ready(arch) => PromiseResult::Ready(Some(arch)),
PromiseResult::Ready(arch) => {
PromiseResult::Ready(Some((results.compound_index, arch)))
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/re_entity_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) use self::entity_tree::{ClearCascade, CompactedStoreEvents};
use re_log_types::DataTableError;
pub use re_log_types::{EntityPath, EntityPathPart, TimeInt, Timeline};

pub use re_query2::{ExtraQueryHistory, VisibleHistory, VisibleHistoryBoundary};
pub use re_query_cache::{ExtraQueryHistory, VisibleHistory, VisibleHistoryBoundary};

#[cfg(feature = "serde")]
pub use blueprint::components::EntityPropertiesComponent;
Expand All @@ -43,7 +43,6 @@ pub use editable_auto_value::EditableAutoValue;

pub mod external {
pub use re_data_store;
pub use re_query2;
pub use re_query_cache;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ re_log_types.workspace = true
re_data_store.workspace = true
re_entity_db.workspace = true
re_query.workspace = true
re_query2.workspace = true
re_query_cache.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true
re_types.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view/src/space_view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use itertools::{FoldWhile, Itertools};
use nohash_hasher::IntMap;
use re_entity_db::external::re_query2::PromiseResult;
use re_entity_db::external::re_query_cache::PromiseResult;

use crate::SpaceViewContents;
use re_data_store::LatestAtQuery;
Expand Down Expand Up @@ -127,7 +127,7 @@ impl SpaceViewBlueprint {
// TODO(#5607): what should happen if the promise is still pending?
None
}
PromiseResult::Ready(arch) => arch,
PromiseResult::Ready(arch) => arch.map(|(_, arch)| arch),
PromiseResult::Error(err) => {
if cfg!(debug_assertions) {
re_log::error!("Failed to load SpaceView blueprint: {err}.");
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view/src/space_view_contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use slotmap::SlotMap;
use smallvec::SmallVec;

use re_entity_db::{
external::{re_data_store::LatestAtQuery, re_query2::PromiseResult},
external::{re_data_store::LatestAtQuery, re_query_cache::PromiseResult},
EntityDb, EntityProperties, EntityPropertiesComponent, EntityPropertyMap, EntityTree,
};
use re_log_types::{
Expand Down
7 changes: 6 additions & 1 deletion crates/re_space_view/src/sub_archetypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ where
CachedLatestAtResults: ToArchetype<A>,
{
let path = entity_path_for_space_view_sub_archetype::<A>(space_view_id, blueprint_db.tree());
(blueprint_db.latest_at_archetype(&path, query), path)
(
blueprint_db
.latest_at_archetype(&path, query)
.map(|res| res.map(|(_, arch)| arch)),
path,
)
}

pub fn query_space_view_sub_archetype_or_default<A: Archetype + Default>(
Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view/src/visual_time_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! to reduce the amount of changes in code that is likely to be refactored soon anyways.
use re_log_types::TimeRange;
use re_query2::{ExtraQueryHistory, VisibleHistory, VisibleHistoryBoundary};
use re_query_cache::{ExtraQueryHistory, VisibleHistory, VisibleHistoryBoundary};
use re_types::blueprint::{
components::VisibleTimeRange,
datatypes::{VisibleTimeRangeBoundary, VisibleTimeRangeBoundaryKind},
Expand Down
2 changes: 2 additions & 0 deletions crates/re_space_view_dataframe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ re_data_ui.workspace = true
re_entity_db.workspace = true
re_log_types.workspace = true
re_query.workspace = true
re_query_cache.workspace = true
re_renderer.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true
re_ui.workspace = true
re_viewer_context.workspace = true

Expand Down
11 changes: 7 additions & 4 deletions crates/re_space_view_dataframe/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use re_data_store::{DataStore, LatestAtQuery};
use re_data_ui::item_ui::instance_path_button;
use re_entity_db::{EntityProperties, InstancePath};
use re_log_types::{EntityPath, Timeline};
use re_query::get_component_with_instances;
use re_types_core::components::InstanceKey;
use re_viewer_context::{
SpaceViewClass, SpaceViewClassIdentifier, SpaceViewClassRegistryError, SpaceViewState,
SpaceViewSystemExecutionError, SystemExecutionOutput, UiVerbosity, ViewQuery, ViewerContext,
Expand Down Expand Up @@ -243,9 +243,12 @@ fn sorted_instance_paths_for<'a>(
.into_iter()
.filter(|comp| !comp.is_indicator_component())
.flat_map(|comp| {
get_component_with_instances(store, latest_at_query, entity_path, comp)
.map(|(_, _, comp_inst)| comp_inst.instance_keys())
.unwrap_or_default()
let num_instances = store
.latest_at(latest_at_query, entity_path, comp, &[comp])
.map_or(0, |(_, _, cells)| {
cells[0].as_ref().map_or(0, |cell| cell.num_instances())
});
(0..num_instances).map(|i| InstanceKey(i as _))
})
.filter(|instance_key| !instance_key.is_splat())
.collect::<BTreeSet<_>>() // dedup and sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ fn get_cached_pinhole(
.latest_at_archetype::<re_types::archetypes::Pinhole>(entity_path, query)
.ok()
.flatten()
.map(|arch| {
.map(|(_, arch)| {
(
arch.image_from_camera,
arch.camera_xyz.unwrap_or(ViewCoordinates::RDF),
Expand Down
3 changes: 1 addition & 2 deletions crates/re_space_view_spatial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ fn resolution_from_tensor(

/// Utility for querying a pinhole archetype instance.
///
/// TODO(andreas): It should be possible to convert [`re_query::ArchetypeView`] to its corresponding Archetype for situations like this.
/// TODO(andreas): This is duplicated into `re_viewport`
// TODO(andreas): This is duplicated into `re_viewport`
fn query_pinhole(
entity_db: &re_entity_db::EntityDb,
query: &re_data_store::LatestAtQuery,
Expand Down
Loading
Loading