alamb commented on code in PR #4646:
URL: https://github.com/apache/arrow-rs/pull/4646#discussion_r1285746249
##########
arrow-row/src/interner.rs:
##########
@@ -343,8 +343,19 @@ impl Bucket {
fn size(&self) -> usize {
std::mem::size_of::<Self>()
+ self.slots.capacity() * std::mem::size_of::<Slot>()
+ // and account for the size of any embedded buckets in the slots
+ + self.slot_child_bucket_size()
+ self.next.as_ref().map(|x| x.size()).unwrap_or_default()
}
+
+ /// returns the total size of any recursively allocated `Bucket`s
+ /// in self.slots. This does not include the size of the child Slot itself
+ fn slot_child_bucket_size(&self) -> usize {
+ self.slots
+ .iter()
+ .map(|slot| slot.child.as_ref().map(|x|
x.size()).unwrap_or_default())
+ .sum()
+ }
}
#[cfg(test)]
Review Comment:
I made a test in
[111b43c](https://github.com/apache/arrow-rs/pull/4646/commits/111b43cf1ab02e2ac53ec208982efc3124742e5f)
It is basically a second implementation of size, which one could argue is
unnecessary but I feel good by having a double checj
##########
arrow-row/src/interner.rs:
##########
@@ -343,8 +343,19 @@ impl Bucket {
fn size(&self) -> usize {
std::mem::size_of::<Self>()
+ self.slots.capacity() * std::mem::size_of::<Slot>()
+ // and account for the size of any embedded buckets in the slots
+ + self.slot_child_bucket_size()
+ self.next.as_ref().map(|x| x.size()).unwrap_or_default()
}
+
+ /// returns the total size of any recursively allocated `Bucket`s
+ /// in self.slots. This does not include the size of the child Slot itself
+ fn slot_child_bucket_size(&self) -> usize {
+ self.slots
+ .iter()
+ .map(|slot| slot.child.as_ref().map(|x|
x.size()).unwrap_or_default())
+ .sum()
+ }
}
#[cfg(test)]
Review Comment:
I made a test in
[111b43c](https://github.com/apache/arrow-rs/pull/4646/commits/111b43cf1ab02e2ac53ec208982efc3124742e5f)
It is basically a second implementation of size, which one could argue is
unnecessary but I feel good by having a double check
--
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]