-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix Redundant ScalarValue Boxed Collection #2523
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
Conversation
alamb
left a comment
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.
tustvold
left a comment
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.
I think this PR removes a non-redundant Box<DataType>. Is it possible this is the cause of the size change?
datafusion/common/src/scalar.rs
Outdated
| /// list of nested ScalarValue (boxed to reduce size_of(ScalarValue)) | ||
| #[allow(clippy::box_collection)] | ||
| List(Option<Box<Vec<ScalarValue>>>, Box<DataType>), | ||
| List(Option<Vec<ScalarValue>>, DataType), |
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.
I'm not sure about unboxing DataType here
|
So I got this to not change the size by making @alamb What do you think about |
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
It seems fine to me |
|
so we going with changes below? |
|
If you prefer |
|
@tustvold I added boxing back. as its more consistent, you are right. If you feel we should go to Box<[Field]> let me know |
alamb
left a comment
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.
datafusion/common/src/scalar.rs
Outdated
| for c in 0..columns.len() { | ||
| let column = columns.get_mut(c).unwrap(); | ||
| column.push(values[c].clone()); | ||
| for (i, v) in |
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.
👍 this is a nicer implementation
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.
clippy complained onfor c in 0..columns.len() :)
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.
All the better that removing a layer of Boxing lets clippy fix things more easily 👍
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.
A perhaps more idiomatic way to write this would be something like
for (column, value) in columns.iter_mut().zip(values)
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.
Yes, thats more concise. Fixed in 2 places.
|
I'll wait until tomorrow to see if @tustvold has any more comments, and if not I'll merge it in |
tustvold
left a comment
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.
Other than a minor nit and a questionable test change, this looks good to me 👍
Thank you, and apologies for the back and forth
datafusion/common/src/scalar.rs
Outdated
| for c in 0..columns.len() { | ||
| let column = columns.get_mut(c).unwrap(); | ||
| column.push(values[c].clone()); | ||
| for (i, v) in |
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.
A perhaps more idiomatic way to write this would be something like
for (column, value) in columns.iter_mut().zip(values)
datafusion/core/src/scalar.rs
Outdated
| Some(Box::new(vec![Int64(Some(1)), Int64(Some(5))])), | ||
| Box::new(DataType::Int64), | ||
| Some(vec![Int64(Some(1)), Int64(Some(5))]), | ||
| Box::new(DataType::Int32), |
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.
Why the change in type?
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.
fixed. Thanks for finding that

Which issue does this PR close?
Closes #2449.
Rationale for this change
What changes are included in this PR?
Are there any user-facing changes?