Skip to content

Commit

Permalink
forbid compaction of tagged+untagged data
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed Jan 22, 2025
1 parent 2d5c213 commit 6a40798
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion crates/store/re_chunk/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,35 @@ impl Chunk {
})
}

/// Returns `true` if both chunks share the same descriptors for the components that
/// _they have in common_.
#[inline]
pub fn same_descriptors(&self, rhs: &Self) -> bool {
self.components.values().all(|lhs_per_desc| {
if lhs_per_desc.len() > 1 {
// If it's already in UB land, we might as well give up immediately.
return false;
}

lhs_per_desc.keys().all(|lhs_desc| {
let Some(rhs_per_desc) = rhs.components.get(&lhs_desc.component_name) else {
return true;
};

if rhs_per_desc.len() > 1 {
// If it's already in UB land, we might as well give up immediately.
return false;
}

if let Some(rhs_desc) = rhs_per_desc.keys().next() {
lhs_desc == rhs_desc
} else {
true
}
})
})
}

/// Returns true if two chunks are concatenable.
///
/// To be concatenable, two chunks must:
Expand All @@ -258,7 +287,10 @@ impl Chunk {
/// * Use the same datatypes for the components they have in common.
#[inline]
pub fn concatenable(&self, rhs: &Self) -> bool {
self.same_entity_paths(rhs) && self.same_timelines(rhs) && self.same_datatypes(rhs)
self.same_entity_paths(rhs)
&& self.same_timelines(rhs)
&& self.same_datatypes(rhs)
&& self.same_descriptors(rhs)
}
}

Expand Down

0 comments on commit 6a40798

Please sign in to comment.