Skip to content

Commit

Permalink
Optionall include static chunks in the chunk store range query for al…
Browse files Browse the repository at this point in the history
…l components
  • Loading branch information
zehiko committed Feb 14, 2025
1 parent dd7f1ef commit 20d634d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 21 additions & 3 deletions crates/store/re_chunk_store/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ impl ChunkStore {
chunks
}

/// Returns the most-relevant _temporal_ chunk(s) for the given [`RangeQuery`].
/// Returns the most-relevant chunk(s) for the given [`RangeQuery`]. Optionally, static chunks
/// can be included in the results.
///
/// The returned vector is guaranteed free of duplicates, by definition.
///
Expand All @@ -753,11 +754,12 @@ impl ChunkStore {
/// The caller should filter the returned chunks further (see [`Chunk::range`]) in order to
/// determine how exactly each row of data fit with the rest.
///
/// **This ignores static data.**
///
pub fn range_relevant_chunks_for_all_components(
&self,
query: &RangeQuery,
entity_path: &EntityPath,
include_static: bool,
) -> Vec<Arc<Chunk>> {
re_tracing::profile_function!(format!("{query:?}"));

Expand Down Expand Up @@ -785,7 +787,23 @@ impl ChunkStore {

debug_assert!(chunks.iter().map(|chunk| chunk.id()).all_unique());

chunks
if include_static {
let static_chunks = self
.static_chunk_ids_per_entity
.get(entity_path)
.map(|static_chunks_per_component| {
static_chunks_per_component
.values()
.filter_map(|chunk_id| self.chunks_per_chunk_id.get(chunk_id).cloned())
.collect_vec()
})
.unwrap_or_default();

debug_assert!(static_chunks.iter().map(|chunk| chunk.id()).all_unique());
static_chunks.into_iter().chain(chunks).collect()
} else {
chunks
}
}

fn range<'a>(
Expand Down
2 changes: 2 additions & 0 deletions crates/store/re_chunk_store/tests/reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,7 @@ fn range() -> anyhow::Result<()> {
.range_relevant_chunks_for_all_components(
&RangeQuery::new(timeline_frame_nr, time_range),
&entity_path,
false, /* don't include static chunks */
)
.into_iter()
.map(|chunk| {
Expand Down Expand Up @@ -1074,6 +1075,7 @@ fn range_overlapped_chunks() -> anyhow::Result<()> {
.range_relevant_chunks_for_all_components(
&RangeQuery::new(timeline_frame_nr, time_range),
&entity_path,
false, /* don't include static chunks */
)
.into_iter()
.map(|chunk| {
Expand Down

0 comments on commit 20d634d

Please sign in to comment.