You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/22 11:16:58 UTC

[GitHub] [arrow-rs] tustvold commented on a diff in pull request #3149: feat: `{Field,DataType}::size`

tustvold commented on code in PR #3149:
URL: https://github.com/apache/arrow-rs/pull/3149#discussion_r1029202444


##########
arrow-schema/src/field.rs:
##########
@@ -459,6 +459,21 @@ impl Field {
             }
         }
     }
+
+    /// Return size of this instance in bytes.
+    ///
+    /// Includes the size of `Self`.
+    pub fn size(&self) -> usize {
+        std::mem::size_of_val(self) - std::mem::size_of_val(&self.data_type)
+            + self.data_type.size()
+            + self.name.capacity()
+            + (std::mem::size_of::<(String, String)>() * self.metadata.capacity())

Review Comment:
   I'm not sure how accurate this approximation is, but I imagine probably good enough to a first order



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org