Skip to content

Commit

Permalink
Cached prefix can go away now
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 24, 2024
1 parent 3177ce2 commit 8ba1ca4
Show file tree
Hide file tree
Showing 71 changed files with 254 additions and 276 deletions.
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use egui::NumExt;

use re_entity_db::{external::re_query::CachedLatestAtComponentResults, EntityPath, InstancePath};
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityPath, InstancePath};
use re_types::ComponentName;
use re_ui::SyntaxHighlighting as _;
use re_viewer_context::{UiVerbosity, ViewerContext};
Expand All @@ -14,7 +14,7 @@ use crate::item_ui;
pub struct EntityLatestAtResults {
pub entity_path: EntityPath,
pub component_name: ComponentName,
pub results: Arc<CachedLatestAtComponentResults>,
pub results: Arc<LatestAtComponentResults>,
}

impl DataUi for EntityLatestAtResults {
Expand Down
4 changes: 2 additions & 2 deletions 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::CachedLatestAtComponentResults, EntityDb};
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityDb};
use re_log_types::{external::arrow2, EntityPath};
use re_types::external::arrow2::array::Utf8Array;
use re_viewer_context::{ComponentUiRegistry, UiVerbosity, ViewerContext};
Expand Down Expand Up @@ -62,7 +62,7 @@ fn fallback_component_ui(
_query: &LatestAtQuery,
db: &EntityDb,
_entity_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
// TODO(#5607): what should happen if the promise is still pending?
Expand Down
20 changes: 10 additions & 10 deletions 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::CachedLatestAtComponentResults, EntityDb};
use re_entity_db::{external::re_query::LatestAtComponentResults, EntityDb};
use re_log_types::EntityPath;
use re_types::{
components::{
Expand All @@ -23,7 +23,7 @@ fn edit_color_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_color = component
Expand Down Expand Up @@ -66,7 +66,7 @@ fn edit_text_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_text = component
Expand Down Expand Up @@ -106,7 +106,7 @@ fn edit_name_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_text = component
Expand Down Expand Up @@ -147,7 +147,7 @@ fn edit_scatter_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_scatter = component
Expand Down Expand Up @@ -196,7 +196,7 @@ fn edit_radius_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_radius = component
Expand Down Expand Up @@ -243,7 +243,7 @@ fn edit_marker_shape_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_marker = component
Expand Down Expand Up @@ -329,7 +329,7 @@ fn edit_stroke_width_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_stroke_width = component
Expand Down Expand Up @@ -376,7 +376,7 @@ fn edit_marker_size_ui(
db: &EntityDb,
entity_path: &EntityPath,
override_path: &EntityPath,
component: &CachedLatestAtComponentResults,
component: &LatestAtComponentResults,
instance_key: &re_types::components::InstanceKey,
) {
let current_marker_size = component
Expand Down Expand Up @@ -425,7 +425,7 @@ fn register_editor<'a, C: Component + Loggable + 'static>(
&EntityDb,
&EntityPath,
&EntityPath,
&CachedLatestAtComponentResults,
&LatestAtComponentResults,
&re_types::components::InstanceKey,
),
) where
Expand Down
8 changes: 4 additions & 4 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl EntityDb {
query: &re_data_store::LatestAtQuery,
) -> PromiseResult<Option<((re_log_types::TimeInt, RowId), A)>>
where
re_query::CachedLatestAtResults: re_query::ToArchetype<A>,
re_query::LatestAtResults: re_query::ToArchetype<A>,
{
let results = self.query_caches().latest_at(
self.store(),
Expand Down Expand Up @@ -240,7 +240,7 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<re_query::CachedLatestAtMonoResult<C>> {
) -> Option<re_query::LatestAtMonoResult<C>> {
self.query_caches().latest_at_component::<C>(
self.store(),
self.resolver(),
Expand All @@ -254,7 +254,7 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<re_query::CachedLatestAtMonoResult<C>> {
) -> Option<re_query::LatestAtMonoResult<C>> {
self.query_caches().latest_at_component_quiet::<C>(
self.store(),
self.resolver(),
Expand All @@ -268,7 +268,7 @@ impl EntityDb {
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> Option<(EntityPath, re_query::CachedLatestAtMonoResult<C>)> {
) -> Option<(EntityPath, re_query::LatestAtMonoResult<C>)> {
self.query_caches()
.latest_at_component_at_closest_ancestor::<C>(
self.store(),
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ all-features = true
[features]
default = ["to_archetype"]

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

## Enable codegen helper binaries (generates ClampedZip & RangeZip implementations).
Expand Down
6 changes: 3 additions & 3 deletions crates/re_query/benches/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use itertools::Itertools;
use re_data_store::{DataStore, LatestAtQuery, StoreSubscriber};
use re_log_types::{entity_path, DataRow, EntityPath, RowId, TimeInt, TimeType, Timeline};
use re_query::{clamped_zip_1x1, PromiseResolver};
use re_query::{CachedLatestAtResults, Caches};
use re_query::{Caches, LatestAtResults};
use re_types::{
archetypes::Points2D,
components::{Color, InstanceKey, Position2D, Text},
Expand Down Expand Up @@ -289,7 +289,7 @@ fn query_and_visit_points(

// TODO(jleibs): Add Radius once we have support for it in field_types
for entity_path in paths {
let results: CachedLatestAtResults = caches.latest_at(
let results: LatestAtResults = caches.latest_at(
store,
&query,
entity_path,
Expand Down Expand Up @@ -340,7 +340,7 @@ fn query_and_visit_strings(
let mut strings = Vec::with_capacity(NUM_STRINGS as _);

for entity_path in paths {
let results: CachedLatestAtResults = caches.latest_at(
let results: LatestAtResults = caches.latest_at(
store,
&query,
entity_path,
Expand Down
11 changes: 5 additions & 6 deletions crates/re_query/examples/latest_at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use re_log_types::{build_frame_nr, DataRow, RowId, TimeType, Timeline};
use re_types_core::{Archetype as _, Loggable as _};

use re_query::{
clamped_zip_1x2, CachedLatestAtComponentResults, CachedLatestAtResults, PromiseResolver,
PromiseResult,
clamped_zip_1x2, LatestAtComponentResults, LatestAtResults, PromiseResolver, PromiseResult,
};

// ---
Expand All @@ -28,7 +27,7 @@ fn main() -> anyhow::Result<()> {
//
// They might or might not already be cached. We won't know for sure until we try to access
// each individual component's data below.
let results: CachedLatestAtResults = caches.latest_at(
let results: LatestAtResults = caches.latest_at(
&store,
&query,
&entity_path.into(),
Expand All @@ -41,9 +40,9 @@ fn main() -> anyhow::Result<()> {
// * `get` returns an option
//
// At this point we still don't know whether they are cached or not. That's the next step.
let points: &CachedLatestAtComponentResults = results.get_required(MyPoint::name())?;
let colors: &CachedLatestAtComponentResults = results.get_or_empty(MyColor::name());
let labels: &CachedLatestAtComponentResults = results.get_or_empty(MyLabel::name());
let points: &LatestAtComponentResults = results.get_required(MyPoint::name())?;
let colors: &LatestAtComponentResults = results.get_or_empty(MyColor::name());
let labels: &LatestAtComponentResults = results.get_or_empty(MyLabel::name());

// Then comes the time to resolve/convert and deserialize the data.
// These steps have to be done together for efficiency reasons.
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query/examples/latest_at_archetype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use re_types::{
};
use re_types_core::{Archetype as _, Loggable as _};

use re_query::{clamped_zip_1x2, CachedLatestAtResults, PromiseResolver, PromiseResult};
use re_query::{clamped_zip_1x2, LatestAtResults, PromiseResolver, PromiseResult};

// ---

Expand All @@ -28,7 +28,7 @@ fn main() -> anyhow::Result<()> {
//
// They might or might not already be cached. We won't know for sure until we try to access
// each individual component's data below.
let results: CachedLatestAtResults = caches.latest_at(
let results: LatestAtResults = caches.latest_at(
&store,
&query,
&entity_path.into(),
Expand Down
12 changes: 6 additions & 6 deletions crates/re_query/examples/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use re_log_types::{build_frame_nr, DataRow, RowId, TimeRange, TimeType, Timeline
use re_types_core::{Archetype as _, Loggable as _};

use re_query::{
clamped_zip_1x2, range_zip_1x2, CachedRangeComponentResults, CachedRangeResults,
PromiseResolver, PromiseResult,
clamped_zip_1x2, range_zip_1x2, PromiseResolver, PromiseResult, RangeComponentResults,
RangeResults,
};

// ---
Expand All @@ -28,7 +28,7 @@ fn main() -> anyhow::Result<()> {
//
// They might or might not already be cached. We won't know for sure until we try to access
// each individual component's data below.
let results: CachedRangeResults = caches.range(
let results: RangeResults = caches.range(
&store,
&query,
&entity_path.into(),
Expand All @@ -41,9 +41,9 @@ fn main() -> anyhow::Result<()> {
// * `get` returns an option
//
// At this point we still don't know whether they are cached or not. That's the next step.
let all_points: &CachedRangeComponentResults = results.get_required(MyPoint::name())?;
let all_colors: &CachedRangeComponentResults = results.get_or_empty(MyColor::name());
let all_labels: &CachedRangeComponentResults = results.get_or_empty(MyLabel::name());
let all_points: &RangeComponentResults = results.get_required(MyPoint::name())?;
let all_colors: &RangeComponentResults = results.get_or_empty(MyColor::name());
let all_labels: &RangeComponentResults = results.get_or_empty(MyLabel::name());

// Then comes the time to resolve/convert and deserialize the data.
// These steps have to be done together for efficiency reasons.
Expand Down
20 changes: 10 additions & 10 deletions crates/re_query/src/latest_at/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use re_log_types::{EntityPath, RowId, TimeInt};
use re_types_core::Component;
use re_types_core::{external::arrow2::array::Array, ComponentName};

use crate::{CachedLatestAtComponentResults, Caches, PromiseResolver, PromiseResult};
use crate::{Caches, LatestAtComponentResults, PromiseResolver, PromiseResult};

// ---

impl CachedLatestAtComponentResults {
impl LatestAtComponentResults {
/// Returns the component data as a dense vector.
///
/// Logs a warning and returns `None` if the component is missing or cannot be deserialized.
Expand Down Expand Up @@ -241,12 +241,12 @@ impl CachedLatestAtComponentResults {
// ---

#[derive(Clone)]
pub struct CachedLatestAtMonoResult<C> {
pub struct LatestAtMonoResult<C> {
pub index: (TimeInt, RowId),
pub value: C,
}

impl<C> CachedLatestAtMonoResult<C> {
impl<C> LatestAtMonoResult<C> {
#[inline]
pub fn data_time(&self) -> TimeInt {
self.index.0
Expand All @@ -258,7 +258,7 @@ impl<C> CachedLatestAtMonoResult<C> {
}
}

impl<C: std::ops::Deref> std::ops::Deref for CachedLatestAtMonoResult<C> {
impl<C: std::ops::Deref> std::ops::Deref for LatestAtMonoResult<C> {
type Target = C;

#[inline]
Expand Down Expand Up @@ -287,7 +287,7 @@ impl Caches {
entity_path: &EntityPath,
query: &LatestAtQuery,
level: re_log::Level,
) -> Option<CachedLatestAtMonoResult<C>> {
) -> Option<LatestAtMonoResult<C>> {
re_tracing::profile_function!();

let results = self.latest_at(store, query, entity_path, [C::name()]);
Expand All @@ -303,7 +303,7 @@ impl Caches {
);
None
}
PromiseResult::Ready(data) if data.len() == 1 => Some(CachedLatestAtMonoResult {
PromiseResult::Ready(data) if data.len() == 1 => Some(LatestAtMonoResult {
index,
value: data[0].clone(),
}),
Expand Down Expand Up @@ -343,7 +343,7 @@ impl Caches {
resolver: &PromiseResolver,
entity_path: &EntityPath,
query: &LatestAtQuery,
) -> Option<CachedLatestAtMonoResult<C>> {
) -> Option<LatestAtMonoResult<C>> {
self.latest_at_component_with_log_level(
store,
resolver,
Expand All @@ -368,7 +368,7 @@ impl Caches {
resolver: &PromiseResolver,
entity_path: &EntityPath,
query: &LatestAtQuery,
) -> Option<CachedLatestAtMonoResult<C>> {
) -> Option<LatestAtMonoResult<C>> {
self.latest_at_component_with_log_level(
store,
resolver,
Expand All @@ -385,7 +385,7 @@ impl Caches {
resolver: &PromiseResolver,
entity_path: &EntityPath,
query: &LatestAtQuery,
) -> Option<(EntityPath, CachedLatestAtMonoResult<C>)> {
) -> Option<(EntityPath, LatestAtMonoResult<C>)> {
re_tracing::profile_function!();

let mut cur_entity_path = Some(entity_path.clone());
Expand Down
4 changes: 2 additions & 2 deletions crates/re_query/src/latest_at/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ mod results;
#[cfg(feature = "to_archetype")]
mod to_archetype;

pub use self::helpers::CachedLatestAtMonoResult;
pub use self::helpers::LatestAtMonoResult;
pub use self::query::LatestAtCache;
pub use self::results::{CachedLatestAtComponentResults, CachedLatestAtResults};
pub use self::results::{LatestAtComponentResults, LatestAtResults};
Loading

0 comments on commit 8ba1ca4

Please sign in to comment.