New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Row size methods (#3160) #3163
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -358,6 +358,14 @@ impl SortField { | |
pub fn new_with_options(data_type: DataType, options: SortOptions) -> Self { | ||
Self { options, data_type } | ||
} | ||
|
||
/// Return size of this instance in bytes. | ||
/// | ||
/// Includes the size of `Self`. | ||
pub fn size(&self) -> usize { | ||
self.data_type.size() + std::mem::size_of::<Self>() | ||
- std::mem::size_of::<DataType>() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why minus size of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to count for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Options is counted by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is that, plus any additional memory from nested fields There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, |
||
} | ||
} | ||
|
||
impl RowConverter { | ||
|
@@ -480,6 +488,22 @@ impl RowConverter { | |
}) | ||
.collect() | ||
} | ||
|
||
/// Returns the size of this instance in bytes | ||
/// | ||
/// Includes the size of `Self`. | ||
pub fn size(&self) -> usize { | ||
std::mem::size_of::<Self>() | ||
+ std::mem::size_of_val(&self.interners) | ||
tustvold marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ self.fields.iter().map(|x| x.size()).sum::<usize>() | ||
+ self.interners.capacity() | ||
* std::mem::size_of::<Option<Box<OrderPreservingInterner>>>() | ||
+ self | ||
.interners | ||
.iter() | ||
.filter_map(|x| x.as_ref().map(|x| x.size())) | ||
.sum::<usize>() | ||
} | ||
} | ||
|
||
/// A row-oriented representation of arrow data, that is normalized for comparison. | ||
|
@@ -512,6 +536,16 @@ impl Rows { | |
pub fn iter(&self) -> RowsIter<'_> { | ||
self.into_iter() | ||
} | ||
|
||
/// Returns the size of this instance in bytes | ||
/// | ||
/// Includes the size of `Self`. | ||
pub fn size(&self) -> usize { | ||
// Size of fields is accounted for as part of RowConverter | ||
std::mem::size_of::<Self>() | ||
+ self.buffer.len() | ||
+ self.offsets.len() * std::mem::size_of::<usize>() | ||
} | ||
} | ||
|
||
impl<'a> IntoIterator for &'a Rows { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
twice?