Skip to content

Commit

Permalink
remove ToArchetype
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jun 5, 2024
1 parent 2dcdbec commit 7c938a6
Show file tree
Hide file tree
Showing 50 changed files with 31 additions and 3,588 deletions.
1 change: 0 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4676,7 +4676,6 @@ dependencies = [
"re_tracing",
"re_tuid",
"re_types",
"re_types_blueprint",
"re_types_core",
"seq-macro",
"similar-asserts",
Expand Down
2 changes: 1 addition & 1 deletion crates/re_entity_db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ 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, features = ["to_archetype"] }
re_query.workspace = true
re_smart_channel.workspace = true
re_tracing.workspace = true
re_types_core.workspace = true
Expand Down
44 changes: 0 additions & 44 deletions crates/re_entity_db/src/entity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use re_log_types::{
EntityPathHash, LogMsg, ResolvedTimeRange, ResolvedTimeRangeF, RowId, SetStoreInfo, StoreId,
StoreInfo, StoreKind, TimePoint, Timeline,
};
use re_query::PromiseResult;
use re_types_core::{Archetype, Loggable};

use crate::{ClearCascade, CompactedStoreEvents, Error, TimesPerTimeline};
Expand Down Expand Up @@ -198,49 +197,6 @@ impl EntityDb {
&self.resolver
}

/// Returns `Ok(None)` if any of the required components are missing.
#[inline]
pub fn latest_at_archetype<A: re_types_core::Archetype>(
&self,
entity_path: &EntityPath,
query: &re_data_store::LatestAtQuery,
) -> PromiseResult<Option<((re_log_types::TimeInt, RowId), A)>>
where
re_query::LatestAtResults: re_query::ToArchetype<A>,
{
let results = self.query_caches().latest_at(
self.store(),
query,
entity_path,
A::all_components().iter().copied(), // no generics!
);

use re_query::ToArchetype as _;
match results.to_archetype(self.resolver()).flatten() {
PromiseResult::Pending => PromiseResult::Pending,
PromiseResult::Error(err) => {
// Primary component has never been logged.
if let Some(err) = err.downcast_ref::<re_query::QueryError>() {
if matches!(err, re_query::QueryError::PrimaryNotFound(_)) {
return PromiseResult::Ready(None);
}
}

// Primary component has been cleared.
if let Some(err) = err.downcast_ref::<re_types_core::DeserializationError>() {
if matches!(err, re_types_core::DeserializationError::MissingData { .. }) {
return PromiseResult::Ready(None);
}
}

PromiseResult::Error(err)
}
PromiseResult::Ready(arch) => {
PromiseResult::Ready(Some((results.compound_index, arch)))
}
}
}

/// Queries for the given `component_names` using latest-at semantics.
///
/// See [`re_query::LatestAtResults`] for more information about how to handle the results.
Expand Down
17 changes: 2 additions & 15 deletions crates/re_query/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ all-features = true


[features]
default = ["to_archetype"]

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

## Enable codegen helper binaries (generates ClampedZip & RangeZip implementations).
codegen = []
Expand All @@ -40,10 +37,6 @@ re_tracing.workspace = true
re_tuid.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
Expand All @@ -64,18 +57,12 @@ thiserror.workspace = true
criterion.workspace = true
mimalloc.workspace = true
rand = { workspace = true, features = ["std", "std_rng"] }
re_types.workspace = true
similar-asserts.workspace = true


[lib]
bench = false


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


[[bin]]
name = "clamped_zip"
required-features = ["codegen"]
Expand Down
104 changes: 0 additions & 104 deletions crates/re_query/examples/latest_at_archetype.rs

This file was deleted.

3 changes: 0 additions & 3 deletions crates/re_query/src/latest_at/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ mod helpers;
mod query;
mod results;

#[cfg(feature = "to_archetype")]
mod to_archetype;

pub use self::helpers::LatestAtMonoResult;
pub use self::query::LatestAtCache;
pub use self::results::{LatestAtComponentResults, LatestAtResults};
12 changes: 9 additions & 3 deletions crates/re_query/src/latest_at/results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl LatestAtResults {
}

/// Utility for retrieving a single instance of a component.
pub fn get_instance<T: re_types::Component>(
pub fn get_instance<T: re_types_core::Component>(
&self,
resolver: &PromiseResolver,
index: usize,
Expand All @@ -101,11 +101,17 @@ impl LatestAtResults {
}

/// Utility for retrieving a specific component.
pub fn get_slice<T: re_types::Component>(&self, resolver: &PromiseResolver) -> Option<&[T]> {
pub fn get_slice<T: re_types_core::Component>(
&self,
resolver: &PromiseResolver,
) -> Option<&[T]> {
self.get(T::name()).and_then(|r| r.dense::<T>(resolver))
}

pub fn get_vec<T: re_types::Component>(&self, resolver: &PromiseResolver) -> Option<Vec<T>> {
pub fn get_vec<T: re_types_core::Component>(
&self,
resolver: &PromiseResolver,
) -> Option<Vec<T>> {
self.get_slice(resolver).map(|v| v.to_vec())
}
}
Expand Down
40 changes: 0 additions & 40 deletions crates/re_query/src/latest_at/to_archetype/.gitattributes

This file was deleted.

51 changes: 0 additions & 51 deletions crates/re_query/src/latest_at/to_archetype/annotation_context.rs

This file was deleted.

Loading

0 comments on commit 7c938a6

Please sign in to comment.