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

Chunkify everything left #7032

Merged
merged 12 commits into from
Aug 2, 2024
5 changes: 0 additions & 5 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4527,7 +4527,6 @@ dependencies = [
"re_log",
"re_log_encoding",
"re_log_types",
"re_query",
"re_query2",
"re_smart_channel",
"re_tracing",
Expand Down Expand Up @@ -4890,7 +4889,6 @@ dependencies = [
"re_entity_db",
"re_log",
"re_log_types",
"re_query",
"re_space_view",
"re_space_view_dataframe",
"re_space_view_spatial",
Expand Down Expand Up @@ -4930,7 +4928,6 @@ dependencies = [
"re_entity_db",
"re_log",
"re_log_types",
"re_query",
"re_query2",
"re_tracing",
"re_types_core",
Expand Down Expand Up @@ -5320,7 +5317,6 @@ dependencies = [
"re_log_encoding",
"re_log_types",
"re_memory",
"re_query",
"re_query2",
"re_renderer",
"re_sdk_comms",
Expand Down Expand Up @@ -5392,7 +5388,6 @@ dependencies = [
"re_log",
"re_log_types",
"re_math",
"re_query",
"re_query2",
"re_renderer",
"re_smart_channel",
Expand Down
1 change: 0 additions & 1 deletion crates/store/re_entity_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ re_int_histogram.workspace = true
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_smart_channel.workspace = true
re_tracing.workspace = true
Expand Down
21 changes: 0 additions & 21 deletions crates/store/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ pub struct EntityDb {
/// Stores all components for all entities for all timelines.
data_store: ChunkStore,

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

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

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

Expand All @@ -81,7 +75,6 @@ impl EntityDb {

pub fn with_store_config(store_id: StoreId, store_config: ChunkStoreConfig) -> Self {
let data_store = ChunkStore::new(store_id.clone(), store_config);
let query_caches = re_query::Caches::new(&data_store);
let query_caches2 = re_query2::Caches::new(&data_store);

Self {
Expand All @@ -94,8 +87,6 @@ impl EntityDb {
tree: crate::EntityTree::root(),
time_histogram_per_timeline: Default::default(),
data_store,
resolver: re_query::PromiseResolver::default(),
query_caches,
query_caches2,
stats: IngestionStatistics::new(store_id),
}
Expand Down Expand Up @@ -123,21 +114,11 @@ impl EntityDb {
self.store_info().map(|ri| &ri.application_id)
}

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

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

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

/// Queries for the given `component_names` using latest-at semantics.
///
/// See [`re_query2::LatestAtResults`] for more information about how to handle the results.
Expand Down Expand Up @@ -384,7 +365,6 @@ impl EntityDb {
// Update our internal views by notifying them of resulting [`ChunkStoreEvent`]s.
self.times_per_timeline.on_events(&store_events);
self.time_histogram_per_timeline.on_events(&store_events);
self.query_caches.on_events(&store_events);
self.query_caches2.on_events(&store_events);
self.tree.on_store_additions(&store_events);

Expand Down Expand Up @@ -445,7 +425,6 @@ impl EntityDb {
re_tracing::profile_function!();

self.times_per_timeline.on_events(store_events);
self.query_caches.on_events(store_events);
self.query_caches2.on_events(store_events);
self.time_histogram_per_timeline.on_events(store_events);
self.tree.on_store_deletions(&self.data_store, store_events);
Expand Down
1 change: 0 additions & 1 deletion crates/store/re_entity_db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub use re_log_types::{EntityPath, EntityPathPart, TimeInt, Timeline};

pub mod external {
pub use re_chunk_store;
pub use re_query;
pub use re_query2;
}

Expand Down
10 changes: 3 additions & 7 deletions crates/store/re_entity_db/tests/clear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use re_log_types::{
example_components::{MyColor, MyIndex, MyPoint},
EntityPath, StoreId, TimeInt, TimePoint, Timeline,
};
use re_query::PromiseResolver;
use re_types_core::{archetypes::Clear, components::ClearIsRecursive, AsComponents};

// ---
Expand All @@ -22,15 +21,12 @@ fn query_latest_component<C: re_types_core::Component>(
) -> Option<(TimeInt, RowId, C)> {
re_tracing::profile_function!();

let resolver = PromiseResolver::default();

let results = db
.query_caches()
.query_caches2()
.latest_at(db.store(), query, entity_path, [C::name()]);
let results = results.get_required(C::name()).ok()?;

let &(data_time, row_id) = results.index();
let data = results.dense::<C>(&resolver)?.first().cloned()?;
let (data_time, row_id) = results.index();
let data = results.component_mono::<C>()?;

Some((data_time, row_id, data))
}
Expand Down
2 changes: 0 additions & 2 deletions crates/viewer/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ fn annotation_info(
query: &re_chunk_store::LatestAtQuery,
keypoint_id: KeypointId,
) -> Option<AnnotationInfo> {
// TODO(#5607): what should happen if the promise is still pending?

// TODO(#6358): this needs to use the index of the keypoint to look up the correct
// class_id. For now we use `latest_at_component_quiet` to avoid the warning spam.
let (_, class_id) = ctx
Expand Down
40 changes: 21 additions & 19 deletions crates/viewer/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use egui::NumExt;

use re_entity_db::{external::re_query::LatestAtComponentResults, EntityPath, InstancePath};
use re_log_types::Instance;
use re_chunk_store::UnitChunkShared;
use re_entity_db::{EntityPath, InstancePath};
use re_log_types::{Instance, TimeInt};
use re_types::ComponentName;
use re_ui::{ContextExt as _, SyntaxHighlighting as _};
use re_viewer_context::{UiLayout, ViewerContext};

Expand All @@ -11,7 +13,8 @@ use crate::item_ui;
/// All the values of a specific [`re_log_types::ComponentPath`].
pub struct EntityLatestAtResults<'a> {
pub entity_path: EntityPath,
pub results: &'a LatestAtComponentResults,
pub component_name: ComponentName,
pub unit: &'a UnitChunkShared,
}

impl<'a> DataUi for EntityLatestAtResults<'a> {
Expand All @@ -23,17 +26,11 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
query: &re_chunk_store::LatestAtQuery,
db: &re_entity_db::EntityDb,
) {
let Some(component_name) = self.results.component_name(db.resolver()) else {
// TODO(#5607): what should happen if the promise is still pending?
return;
};

re_tracing::profile_function!(component_name);
re_tracing::profile_function!(self.component_name);

// TODO(#5607): what should happen if the promise is still pending?
let Some(num_instances) = self
.results
.raw(db.resolver(), component_name)
.unit
.component_batch_raw(&self.component_name)
.map(|data| data.len())
else {
ui.weak("<pending>");
Expand All @@ -56,7 +53,10 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {

// Display data time and additional diagnostic information for static components.
if ui_layout != UiLayout::List {
let time = self.results.index().0;
let time = self
.unit
.index(&query.timeline())
.map_or(TimeInt::STATIC, |(time, _)| time);
if time.is_static() {
// No need to show anything here. We already tell the user this is a static component elsewhere.
} else {
Expand All @@ -71,10 +71,10 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
}

// if the component is static, we display extra diagnostic information
if self.results.is_static() {
if self.unit.is_static() {
let static_message_count = db
.store()
.num_static_events_for_component(&self.entity_path, component_name);
.num_static_events_for_component(&self.entity_path, self.component_name);
if static_message_count > 1 {
ui.label(ui.ctx().warning_text(format!(
"Static component value was overridden {} times",
Expand All @@ -91,7 +91,7 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
db.store().num_temporal_events_for_component_on_timeline(
&query.timeline(),
&self.entity_path,
component_name,
self.component_name,
);
if temporal_message_count > 0 {
ui.label(ui.ctx().error_text(format!(
Expand Down Expand Up @@ -142,7 +142,8 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
query,
db,
&self.entity_path,
self.results,
self.component_name,
self.unit,
&Instance::from(0),
);
} else if one_line {
Expand All @@ -160,7 +161,7 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
ui.label("Index");
});
header.col(|ui| {
ui.label(component_name.short_name());
ui.label(self.component_name.short_name());
});
})
.body(|mut body| {
Expand Down Expand Up @@ -189,7 +190,8 @@ impl<'a> DataUi for EntityLatestAtResults<'a> {
query,
db,
&self.entity_path,
self.results,
self.component_name,
self.unit,
&instance,
);
});
Expand Down
7 changes: 4 additions & 3 deletions crates/viewer/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ impl DataUi for ComponentPath {
));
} else {
let results =
db.query_caches()
db.query_caches2()
.latest_at(db.store(), query, entity_path, [*component_name]);
if let Some(results) = results.components.get(component_name) {
if let Some(unit) = results.components.get(component_name) {
crate::EntityLatestAtResults {
entity_path: entity_path.clone(),
results: results.as_ref(),
component_name: *component_name,
unit,
}
.data_ui(ctx, ui, ui_layout, query, db);
} else if ctx.recording().tree().subtree(entity_path).is_some() {
Expand Down
1 change: 0 additions & 1 deletion crates/viewer/re_data_ui/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ impl EntityDataUi for re_types::components::TensorData {
) {
re_tracing::profile_function!();

// TODO(#5607): what should happen if the promise is still pending?
let tensor_data_row_id = ctx
.recording()
.latest_at_component::<Self>(entity_path, query)
Expand Down
10 changes: 6 additions & 4 deletions crates/viewer/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ impl DataUi for InstancePath {
.with_icon(icon),
)
} else {
let results = db.query_caches().latest_at(
let results = db.query_caches2().latest_at(
db.store(),
query,
entity_path,
[component_name],
);
let Some(results) = results.components.get(&component_name) else {
let Some(unit) = results.components.get(&component_name) else {
continue; // no need to show components that are unset at this point in time
};

Expand All @@ -123,7 +123,8 @@ impl DataUi for InstancePath {
if instance.is_all() {
crate::EntityLatestAtResults {
entity_path: entity_path.clone(),
results: results.as_ref(),
component_name,
unit,
}
.data_ui(
ctx,
Expand All @@ -140,7 +141,8 @@ impl DataUi for InstancePath {
query,
db,
entity_path,
results,
component_name,
unit,
instance,
);
}
Expand Down
1 change: 0 additions & 1 deletion crates/viewer/re_selection_panel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ re_data_ui.workspace = true
re_entity_db.workspace = true
re_log_types.workspace = true
re_log.workspace = true
re_query.workspace = true
re_space_view_dataframe.workspace = true
re_space_view_spatial.workspace = true
re_space_view_time_series.workspace = true
Expand Down
Loading
Loading