Skip to content

Commit

Permalink
an archetype query is timed by its most recent component
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 9, 2024
1 parent b5364bc commit 64f9cf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/re_data_store/src/store_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl DataStore {
/// Queries the datastore for the cells of the specified `components`, as seen from the point
/// of view of the so-called `primary` component.
///
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// success.
/// Success is defined by one thing and one thing only: whether a cell could be found for the
/// `primary` component.
Expand Down Expand Up @@ -533,7 +533,7 @@ impl IndexedTable {
/// Queries the table for the cells of the specified `components`, as seen from the point
/// of view of the so-called `primary` component.
///
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// success, or `None` iff no cell could be found for the `primary` component.
pub fn latest_at<const N: usize>(
&self,
Expand Down Expand Up @@ -731,7 +731,7 @@ impl IndexedBucket {
/// Queries the bucket for the cells of the specified `components`, as seen from the point
/// of view of the so-called `primary` component.
///
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// Returns an array of [`DataCell`]s (as well as the associated _data_ time and `RowId`) on
/// success, or `None` iff no cell could be found for the `primary` component.
pub fn latest_at<const N: usize>(
&self,
Expand Down
7 changes: 4 additions & 3 deletions crates/re_query/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ pub fn get_component_with_instances(
))
}

/// Retrieve an [`ArchetypeView`] from the `DataStore`
/// Retrieve an [`ArchetypeView`] from the `DataStore`, as well as the associated _data_ time of
/// its _most recent component_.
///
/// If you expect only one instance (e.g. for mono-components like `Transform` `Tensor`]
/// and have no additional components you can use [`DataStore::query_latest_component`] instead.
Expand Down Expand Up @@ -144,7 +145,7 @@ pub fn query_archetype<A: Archetype>(
let (data_times, row_ids, required_components): (Vec<_>, Vec<_>, Vec<_>) =
required_components.into_iter().flatten().multiunzip();

let data_time = data_times.first().unwrap_or(&None);
let max_data_time = data_times.iter().max().unwrap_or(&None);
let row_id = row_ids.first().unwrap_or(&RowId::ZERO);

let recommended_components = A::recommended_components();
Expand All @@ -159,7 +160,7 @@ pub fn query_archetype<A: Archetype>(
});

Ok((
*data_time,
*max_data_time,
ArchetypeView::from_components(
*row_id,
required_components.into_iter().chain(other_components),
Expand Down

0 comments on commit 64f9cf4

Please sign in to comment.