-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Avoid clones in make_array for StructArray and GenericByteViewArray
#9114
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
Changes from all commits
372b59c
4895eda
c5b727f
59d9035
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 |
|---|---|---|
|
|
@@ -347,25 +347,26 @@ impl StructArray { | |
|
|
||
| impl From<ArrayData> for StructArray { | ||
| fn from(data: ArrayData) -> Self { | ||
| let parent_offset = data.offset(); | ||
| let parent_len = data.len(); | ||
| let (data_type, len, nulls, offset, _buffers, child_data) = data.into_parts(); | ||
|
|
||
| let fields = data | ||
| .child_data() | ||
| .iter() | ||
| let parent_offset = offset; | ||
| let parent_len = len; | ||
|
|
||
| let fields = child_data | ||
| .into_iter() | ||
| .map(|cd| { | ||
| if parent_offset != 0 || parent_len != cd.len() { | ||
| make_array(cd.slice(parent_offset, parent_len)) | ||
|
Contributor
Author
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. we can probably avoid an additional allocation for sliced arrays by making a version of
Contributor
Author
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. I filed a ticket to track this idea |
||
| } else { | ||
| make_array(cd.clone()) | ||
| make_array(cd) | ||
|
Contributor
Author
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.
|
||
| } | ||
| }) | ||
| .collect(); | ||
|
|
||
| Self { | ||
| len: data.len(), | ||
| data_type: data.data_type().clone(), | ||
| nulls: data.nulls().cloned(), | ||
| len, | ||
| data_type, | ||
| nulls, | ||
| fields, | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
cloneing the buffers is relatively cheap (they areArcd internally) so avoiding this just makes the code easier to follow, I don't think it will be any significant performance savings