rustyconover commented on code in PR #9445:
URL: https://github.com/apache/arrow-rs/pull/9445#discussion_r3221377817
##########
arrow-array/src/record_batch.rs:
##########
@@ -229,6 +230,38 @@ pub struct RecordBatch {
///
/// This is stored separately from the columns to handle the case of no
columns
row_count: usize,
+
+ /// Per-batch custom metadata
+ ///
+ /// This corresponds to the `custom_metadata` field on the IPC `Message`
+ /// flatbuffer, allowing per-batch metadata separate from schema-level
+ /// metadata. Stored as `Option<Arc<...>>` so that a `RecordBatch` without
+ /// custom metadata adds only a pointer's worth of overhead, and clones
+ /// share the map.
+ custom_metadata: Option<Arc<HashMap<String, String>>>,
+}
+
+// Custom equality: a batch built with an empty metadata map compares equal to
+// one built without any metadata at all. This is also reachable via
+// `custom_metadata_mut().clear()`, so we collapse the two forms here rather
+// than letting the derived impl surface the distinction.
+impl PartialEq for RecordBatch {
+ fn eq(&self, other: &Self) -> bool {
+ if self.row_count != other.row_count || self.schema != other.schema {
+ return false;
+ }
+ if self.columns != other.columns {
+ return false;
+ }
Review Comment:
I guess it depends. custom_metadata is rare in practice. I can move the
order if you think its worth it.
--
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]