You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add Metadata::retain to filter entries in place #10683
While updating DataFusion to arrow 60 I found the new Metadata struct introduced in #10075 has no way to remove entries based on a predicate. Code that previously called HashMap::retain on field/schema metadata now has to convert to a BTreeMap, filter, and convert back.
For example, DataFusion computes the intersection of metadata across UNION inputs, which now looks like:
letmut intersected:Option<BTreeMap<String,String>> = None;for metadata in metadatas {match&mut intersected {None => {// deep copy into a BTreeMap so we can filter it below
intersected =
Some(metadata.iter().map(|(k, v)| (k.clone(), v.clone())).collect());}Some(current) => {
current.retain(|k, v| metadata.get(k) == Some(&*v));}}}
intersected.map(Metadata::from).unwrap_or_default()
Describe the solution you'd like
A Metadata::retain(|k, v| ...) method, copy-on-write like the existing insert/remove. The code above would then stay in terms of Metadata and avoid the deep copy and round-trip:
Activity
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)
implement `Metadata::retain` (apache#10695)