emilk opened a new issue, #7628:
URL: https://github.com/apache/arrow-rs/issues/7628
## Problem
I have a `mut RecordBatch` and I want to insert a key:value pair into its
metadata.
Currently this is not only very unergonomic, it is also unnecessarily slow:
```rs
let mut new_schema = std::sync::Arc::unwrap_or_clone(record_batch.schema());
new_schema.metadata.insert(key, value);
let record_batch = record_batch
.with_schema(new_schema.into())
.expect("Can't fail");
```
## Wanted solution
Modifying the metadata should not be difficult or slow. I suggest we expose
the RecordBatch metadata with:
```rs
impl RecordBatch {
fn metadata_mut(&mut self) -> &mut HashMap<String, String> {
let schema = Arc::make_mut(&mut self.schema);
&mut schema.metadata
}
}
```
Thus enabling users to just write:
```rs
record_batch.metadata_mut().insert(key, value);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]