-
Notifications
You must be signed in to change notification settings - Fork 185
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
Moving AuxiliaryKeys
to DataRequest
as DataKeyAttributes
#4981
Conversation
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 reviewed the changes in icu_provider
, icu_provider_blob
, and parts of icu_datagen
. I assume the rest of the changes are mechanical.
Praise: nice work! Thanks for keeping the output data the same in order to make this a more standalone change.
/// TODO | ||
#[derive(Clone, Default)] | ||
pub struct DataKeyAttributes { |
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.
TODO
(here and elsewhere)
key_attributes: &DataKeyAttributes, | ||
) -> Result<bool, DataError> { | ||
self.supported_requests() | ||
.map(|v| v.contains(&(locale.clone(), key_attributes.clone()))) |
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.
Thought/Issue: This is a hot path and it's a pity you need to clone; there should be a way to do the lookup without cloning.
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.
yes there should be...
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.
Could work with HashMap<DataKeyAttributes, HashSet<DataLocale>>
instead?
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.
There's some discussion of options in https://stackoverflow.com/questions/45786717/how-to-implement-hashmap-with-two-keys
Doubly-nested HashMap is interesting, but that's a helluva lot of hashmaps...
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.
Or, since you need this tuple everywhere, maybe just export a helper struct called LocaleWithAttributes
(a standalone helper used in IterableDataProvider but not DataRequest) with all the impls you need.
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.
Can I do this in a follow-up? I don't want this to get stale
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.
Follow-up is okay
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.
Please also look at |
components/experimental/tests/transliterate/data/baked/macros/normalizer_comp_v1.rs.data
Show resolved
Hide resolved
write!(&mut path_buf, "/{key}").expect("infallible"); | ||
write!(&mut path_buf, "/{locale}").expect("infallible"); | ||
if !key_attributes.is_empty() { | ||
write!(&mut path_buf, "-x-{}", key_attributes as &str).expect("infallible"); | ||
} | ||
write!(&mut path_buf, ".{}", self.manifest.file_extension).expect("infallible"); |
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.
Thought for later: we probably want to have fs provider create another directory layer instead of using -x-
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.
yep, we can improve the representation for all providers
key_attributes: &DataKeyAttributes, | ||
) -> Result<bool, DataError> { | ||
self.supported_requests() | ||
.map(|v| v.contains(&(locale.clone(), key_attributes.clone()))) |
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.
There's some discussion of options in https://stackoverflow.com/questions/45786717/how-to-implement-hashmap-with-two-keys
Doubly-nested HashMap is interesting, but that's a helluva lot of hashmaps...
The difference is in the The new code deduplicates more aggressively; for example, it finds the following match that the old code did not find:
I'm trying to investigate why. |
I added more printing to the old code, and I get this message
I don't know why it thinks |
Ok, it appears to be a bug in the LocaleFallbacker where it doesn't ignore the aux keys when it should, which is effectively fixed by removing aux keys from DataLocale. #4983 |
Thanks for investigating. |
Co-authored-by: Shane F. Carr <[email protected]>
@@ -66,7 +66,7 @@ impl WeekCalculator { | |||
&provider.as_downcasting(), | |||
DataRequest { | |||
locale, | |||
metadata: Default::default(), | |||
..Default::default() |
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.
Thought: using ..Default::default()
means that if we ever refactor DataRequest
again, we won't get compiler errors for missing fields, which I think was an important part of building this PR.
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.
Didn't really need or use that. Searching for DataRequest {
is exhaustive because there are no constructors.
#3632