mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
Apply PR requests related to Refactor the FieldIdMapWithMetadata
This commit is contained in:
parent
b88aa9cc76
commit
8ec0c322ea
4 changed files with 49 additions and 19 deletions
|
@ -107,8 +107,15 @@ impl<'indexing> GlobalFieldsIdsMap<'indexing> {
|
|||
}
|
||||
|
||||
/// Get the metadata of a field based on its id.
|
||||
pub fn metadata(&self, id: FieldId) -> Option<Metadata> {
|
||||
self.local.metadata(id).or_else(|| self.global.read().unwrap().metadata(id))
|
||||
pub fn metadata(&mut self, id: FieldId) -> Option<Metadata> {
|
||||
if self.local.metadata(id).is_none() {
|
||||
let global = self.global.read().unwrap();
|
||||
|
||||
let (name, metadata) = global.name_with_metadata(id)?;
|
||||
self.local.insert(name, id, metadata);
|
||||
}
|
||||
|
||||
self.local.metadata(id)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue