rustyconover commented on PR #9445:
URL: https://github.com/apache/arrow-rs/pull/9445#issuecomment-4422635290

   hi @jhorstmann, I just switched the field to `Option<Arc<HashMap<String, 
String>>>`. `RecordBatch` is now 48 bytes (one niche-optimized pointer added 
vs. the original 40), and clones bump an `Arc` refcount instead of copying the 
map.
   
   Took the chance to keep the public API minimal — four methods on 
`RecordBatch`:
   
   ```rust
   fn custom_metadata(&self) -> Option<&HashMap<String, String>>;
   fn custom_metadata_mut(&mut self) -> &mut HashMap<String, String>;
   fn with_custom_metadata(self, HashMap<String, String>) -> Self;  // empty -> 
None
   fn into_parts_with_custom_metadata(self) -> (..., Option<HashMap<String, 
String>>);
   ```
   
   `with_custom_metadata` normalizes an empty map to `None`. Since 
`custom_metadata_mut().clear()` can't observe the post-mutation state, 
`PartialEq` treats `Some(empty)` and `None` as equal — the two paths to "no 
metadata" stay indistinguishable to callers.
   


-- 
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]

Reply via email to