Skip to content

Commit

Permalink
more unneeded Cached prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Apr 19, 2024
1 parent 89b2102 commit 59a03aa
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
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
16 changes: 8 additions & 8 deletions crates/re_query/src/latest_at/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ impl LatestAtComponentResults {
// ---

#[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
2 changes: 1 addition & 1 deletion 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::{LatestAtComponentResults, LatestAtResults};
4 changes: 2 additions & 2 deletions crates/re_query/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ pub use self::visible_history::{ExtraQueryHistory, VisibleHistory, VisibleHistor
pub use self::cache::{CacheKey, Caches};
pub use self::cache_stats::{CachedComponentStats, CachesStats};
pub use self::flat_vec_deque::{ErasedFlatVecDeque, FlatVecDeque};
pub use self::latest_at::{CachedLatestAtMonoResult, LatestAtComponentResults, LatestAtResults};
pub use self::range::{CachedRangeData, RangeComponentResults, RangeResults};
pub use self::latest_at::{LatestAtMonoResult, LatestAtComponentResults, LatestAtResults};
pub use self::range::{RangeData, RangeComponentResults, RangeResults};

pub(crate) use self::latest_at::LatestAtCache;
pub(crate) use self::range::{RangeCache, RangeComponentResultsInner};
Expand Down
2 changes: 1 addition & 1 deletion crates/re_query/src/range/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ mod results;

pub use self::query::RangeCache;
pub use self::results::{
RangeComponentResults, RangeComponentResultsInner, CachedRangeData,
RangeComponentResults, RangeComponentResultsInner, RangeData,
RangeResults,
};
14 changes: 7 additions & 7 deletions crates/re_query/src/range/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl std::ops::Deref for RangeComponentResults {
// TODO: I see no reason why we couldnt put the query range in there, simplifying the life of
// downstream consumers.
#[derive(Debug)]
pub struct CachedRangeData<'a, T> {
pub struct RangeData<'a, T> {
// TODO(Amanieu/parking_lot#289): we need two distinct mapped guards because it's
// impossible to return an owned type in a `parking_lot` guard.
// See <https://github.com/Amanieu/parking_lot/issues/289#issuecomment-1827545967>.
Expand All @@ -171,15 +171,15 @@ pub struct CachedRangeData<'a, T> {
reentering: &'static std::thread::LocalKey<RefCell<u32>>,
}

impl<'a, T> Drop for CachedRangeData<'a, T> {
impl<'a, T> Drop for RangeData<'a, T> {
#[inline]
fn drop(&mut self) {
self.reentering
.with_borrow_mut(|reentering| *reentering = reentering.saturating_sub(1));
}
}

impl<'a, T> CachedRangeData<'a, T> {
impl<'a, T> RangeData<'a, T> {
/// Returns the current status on both ends of the range.
///
/// E.g. it is possible that the front-side of the range is still waiting for pending data while
Expand Down Expand Up @@ -255,7 +255,7 @@ impl RangeComponentResults {
/// Use [`PromiseResult::flatten`] to merge the results of resolving the promise and of
/// deserializing the data into a single one, if you don't need the extra flexibility.
#[inline]
pub fn to_dense<C: Component>(&self, resolver: &PromiseResolver) -> CachedRangeData<'_, C> {
pub fn to_dense<C: Component>(&self, resolver: &PromiseResolver) -> RangeData<'_, C> {
// --- Step 1: try and upsert pending data (write lock) ---

thread_local! {
Expand Down Expand Up @@ -467,7 +467,7 @@ impl RangeComponentResults {
.unwrap()
});

CachedRangeData {
RangeData {
indices,
data,
time_range: self.time_range,
Expand All @@ -490,7 +490,7 @@ impl RangeComponentResults {
pub fn to_sparse<C: Component>(
&self,
resolver: &PromiseResolver,
) -> CachedRangeData<'_, Option<C>> {
) -> RangeData<'_, Option<C>> {
// --- Step 1: try and upsert pending data (write lock) ---

thread_local! {
Expand Down Expand Up @@ -702,7 +702,7 @@ impl RangeComponentResults {
.unwrap()
});

CachedRangeData {
RangeData {
indices,
data,
time_range: self.time_range,
Expand Down
10 changes: 5 additions & 5 deletions crates/re_space_view_spatial/src/visualizers/results_ext.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use re_query::{CachedRangeData, LatestAtResults, PromiseResolver, PromiseResult, RangeResults};
use re_query::{RangeData, LatestAtResults, PromiseResolver, PromiseResult, RangeResults};
use re_types::Component;

// --- Cached ---
Expand Down Expand Up @@ -49,20 +49,20 @@ pub trait RangeResultsExt {
fn get_dense<'a, C: Component>(
&'a self,
resolver: &PromiseResolver,
) -> Option<re_query::Result<CachedRangeData<'a, C>>>;
) -> Option<re_query::Result<RangeData<'a, C>>>;

fn get_or_empty_dense<'a, C: Component>(
&'a self,
resolver: &PromiseResolver,
) -> re_query::Result<CachedRangeData<'a, C>>;
) -> re_query::Result<RangeData<'a, C>>;
}

impl RangeResultsExt for RangeResults {
#[inline]
fn get_dense<'a, C: Component>(
&'a self,
resolver: &PromiseResolver,
) -> Option<re_query::Result<CachedRangeData<'a, C>>> {
) -> Option<re_query::Result<RangeData<'a, C>>> {
let results = self.get(C::name())?.to_dense(resolver);

// TODO(#5607): what should happen if the promise is still pending?
Expand All @@ -83,7 +83,7 @@ impl RangeResultsExt for RangeResults {
fn get_or_empty_dense<'a, C: Component>(
&'a self,
resolver: &PromiseResolver,
) -> re_query::Result<CachedRangeData<'a, C>> {
) -> re_query::Result<RangeData<'a, C>> {
let results = self.get_or_empty(C::name()).to_dense(resolver);

// TODO(#5607): what should happen if the promise is still pending?
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_tensor/src/visualizer_system.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::CachedLatestAtMonoResult, EntityPath};
use re_entity_db::{external::re_query::LatestAtMonoResult, EntityPath};
use re_log_types::RowId;
use re_types::{archetypes::Tensor, components::TensorData, tensor_data::DecodedTensor};
use re_viewer_context::{
Expand Down Expand Up @@ -56,7 +56,7 @@ impl TensorSystem {
&mut self,
ctx: &ViewerContext<'_>,
ent_path: &EntityPath,
tensor: CachedLatestAtMonoResult<TensorData>,
tensor: LatestAtMonoResult<TensorData>,
) {
let row_id = tensor.row_id();
match ctx
Expand Down
4 changes: 2 additions & 2 deletions crates/re_space_view_text_log/src/visualizer_system.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use re_data_store::TimeRange;
use re_entity_db::EntityPath;
use re_log_types::{RowId, TimeInt};
use re_query::{clamped_zip_1x2, range_zip_1x2, CachedRangeData, PromiseResult};
use re_query::{clamped_zip_1x2, range_zip_1x2, RangeData, PromiseResult};
use re_types::{
archetypes::TextLog,
components::{Color, Text, TextLogLevel},
Expand Down Expand Up @@ -132,7 +132,7 @@ impl VisualizerSystem for TextLogSystem {
// TODO(#5607): what should happen if the promise is still pending?
#[inline]
fn check_range<'a, C: Component>(
results: &'a CachedRangeData<'a, C>,
results: &'a RangeData<'a, C>,
) -> re_query::Result<()> {
let (front_status, back_status) = results.status();
match front_status {
Expand Down

0 comments on commit 59a03aa

Please sign in to comment.