Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Avoid clone in with_validity #1104

Merged
merged 1 commit into from
Jun 26, 2022
Merged

Avoid clone in with_validity #1104

merged 1 commit into from
Jun 26, 2022

Conversation

jorgecarleitao
Copy link
Owner

This PR modifies the concrete implementations of with_validity to not clone the arrays unless explicitly requires.

The motivation is that when an array is cloned, it becomes immutable (an O(N) clone of the data is required to mutate it). Thus, we should only clone when the user needs to clone.

Migration

To migrate, use array.clone().with_validity(...) instead of array.with_validity(...) when clone is required.

@codecov
Copy link

codecov bot commented Jun 25, 2022

Codecov Report

Merging #1104 (dcb1a7e) into main (88f05bb) will decrease coverage by 0.02%.
The diff coverage is 37.14%.

@@            Coverage Diff             @@
##             main    #1104      +/-   ##
==========================================
- Coverage   81.24%   81.21%   -0.03%     
==========================================
  Files         366      366              
  Lines       35336    35352      +16     
==========================================
+ Hits        28707    28711       +4     
- Misses       6629     6641      +12     
Impacted Files Coverage Δ
src/array/dictionary/mod.rs 79.61% <0.00%> (+0.76%) ⬆️
src/array/fixed_size_list/mod.rs 63.12% <0.00%> (-0.80%) ⬇️
src/array/list/mod.rs 82.65% <0.00%> (-0.86%) ⬇️
src/array/map/mod.rs 59.11% <0.00%> (-3.97%) ⬇️
src/array/mod.rs 68.54% <ø> (ø)
src/array/null.rs 45.67% <ø> (ø)
src/array/struct_/mod.rs 61.45% <0.00%> (-0.70%) ⬇️
src/compute/comparison/binary.rs 72.51% <0.00%> (ø)
src/array/primitive/mod.rs 79.62% <40.00%> (+0.08%) ⬆️
src/compute/comparison/boolean.rs 79.09% <66.66%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88f05bb...dcb1a7e. Read the comment docs.

@jorgecarleitao jorgecarleitao merged commit 5b66f5f into main Jun 26, 2022
@jorgecarleitao jorgecarleitao deleted the lazy_clone branch June 26, 2022 13:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant