-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration kernel for the blueprint space-view-related breaking changes #8439
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ mod id; | |
mod iter; | ||
mod latest_at; | ||
mod merge; | ||
mod migration; | ||
mod range; | ||
mod shuffle; | ||
mod slice; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
use arrow2::array::{Array, Utf8Array}; | ||
|
||
use itertools::Itertools; | ||
use nohash_hasher::IntMap; | ||
|
||
use crate::Chunk; | ||
|
||
impl Chunk { | ||
/// A temporary migration kernel for blueprint data. | ||
/// | ||
/// Deals with all the space-view terminology breaking changes (`SpaceView`->`View`, `space_view`->`view`, etc). | ||
#[inline] | ||
pub fn patched_for_blueprint_021_compat(&self) -> Self { | ||
let mut chunk = self.clone(); | ||
|
||
const PATCHES: &[(&str, &str)] = &[("SpaceView", "View"), ("space_view", "view")]; | ||
|
||
// First, patch any entity path that still use space-view terminology. | ||
// We expect this to only ever be called for blueprint data, so these entity paths | ||
// are all builtin ones -- we're not overriding any user data. | ||
let mut entity_path = chunk.entity_path.to_string(); | ||
for (from, to) in PATCHES { | ||
entity_path = entity_path.replace(from, to); | ||
} | ||
chunk.entity_path = entity_path.into(); | ||
|
||
let mut components_patched = IntMap::default(); | ||
for (component_name, per_desc) in chunk.components.iter_mut() { | ||
if PATCHES | ||
.iter() | ||
.any(|(from, _to)| component_name.contains(from)) | ||
{ | ||
// Second, patch all descriptors that still use space-view terminology. | ||
for (mut descriptor, list_array) in std::mem::take(per_desc) { | ||
for (from, to) in PATCHES { | ||
if let Some(archetype_name) = descriptor.archetype_name.as_mut() { | ||
*archetype_name = archetype_name.replace(from, to).into(); | ||
} | ||
descriptor.component_name = | ||
descriptor.component_name.replace(from, to).into(); | ||
} | ||
components_patched.insert(descriptor, list_array.clone()); | ||
} | ||
} | ||
|
||
// Finally, patch actual data that still uses space-view terminology. | ||
// As far as we know, this only concerns `IncludedContent` specifically. | ||
if component_name == "rerun.blueprint.components.IncludedContent" { | ||
for list_array in per_desc.values_mut() { | ||
let arrays = list_array | ||
.iter() | ||
.map(|utf8_array| { | ||
utf8_array.map(|array| { | ||
let Some(array) = array.as_any().downcast_ref::<Utf8Array<i32>>() | ||
else { | ||
// Unreachable, just avoiding unwraps. | ||
return array; | ||
}; | ||
|
||
array | ||
.iter() | ||
.map(|s| { | ||
s.map(|s| { | ||
let mut s = s.to_owned(); | ||
for (from, to) in PATCHES { | ||
s = s.replace(from, to); | ||
} | ||
s | ||
}) | ||
}) | ||
.collect::<Utf8Array<i32>>() | ||
.to_boxed() | ||
}) | ||
}) | ||
.collect_vec(); | ||
let arrays = arrays | ||
.iter() | ||
.map(|a| a.as_deref() as Option<&dyn Array>) | ||
.collect_vec(); | ||
|
||
if let Some(list_array_patched) = crate::util::arrays_to_list_array_opt(&arrays) | ||
{ | ||
*list_array = list_array_patched; | ||
} | ||
} | ||
} | ||
} | ||
|
||
for (desc, list_array) in components_patched { | ||
chunk.components.insert_descriptor(desc, list_array); | ||
} | ||
|
||
chunk | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish we had a version tag on the store so we're not applying this indefinitely into the future ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we need to pull the StoreInfos all the way in at some point. We can do that later though, that's fine (I don't expect this particular change to be particularly version specific --
SpaceView
is not making a come back anytime soon I hope 😛).