Skip to content
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

Implement size_hint and ExactSizedIterator for DecimalArray #1506

Merged
merged 6 commits into from
Mar 30, 2022

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Mar 29, 2022

Which issue does this PR close?

Closes #1505

Rationale for this change

I was doing some small cleanups in DataFusion apache/datafusion#2107 and noticed that the DecimalArray iterators do not report their exact size. The exact size is used in several places for optimizations in Arrow

What changes are included in this PR?

  1. Implement size_hint and ExactSizedIterator for DecimalArray
  2. Tests for same

Are there any user-facing changes?

Can use DecimalArray::iter() in more situations

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 29, 2022
@alamb alamb changed the title Implement size_hint and ExactSizedIterator for DecimalArray Implement size_hint and ExactSizedIterator for DecimalArray Mar 29, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 29, 2022

Codecov Report

Merging #1506 (7218586) into master (4c22315) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #1506   +/-   ##
=======================================
  Coverage   82.73%   82.74%           
=======================================
  Files         188      188           
  Lines       54354    54370   +16     
=======================================
+ Hits        44970    44987   +17     
+ Misses       9384     9383    -1     
Impacted Files Coverage Δ
arrow/src/array/array_binary.rs 92.93% <100.00%> (+0.31%) ⬆️
arrow/src/array/iterator.rs 96.11% <100.00%> (+0.30%) ⬆️
parquet_derive/src/parquet_field.rs 65.75% <0.00%> (-0.46%) ⬇️
parquet/src/encodings/encoding.rs 93.37% <0.00%> (-0.19%) ⬇️
arrow/src/array/transform/mod.rs 86.57% <0.00%> (+0.11%) ⬆️
arrow/src/datatypes/datatype.rs 66.80% <0.00%> (+0.39%) ⬆️

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 4c22315...7218586. Read the comment docs.

}

/// iterator has have known size.
impl<'a> std::iter::ExactSizeIterator for DecimalIter<'a> {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have it in iterator.rs? I see other ExactSizeIterators implementations located there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 that is a good idea. I can certainly move it there.

Copy link
Member

@viirya viirya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me.

@alamb
Copy link
Contributor Author

alamb commented Mar 29, 2022

Thanks for the review @viirya !

@viirya
Copy link
Member

viirya commented Mar 29, 2022

lgtm. thanks @alamb !

@alamb alamb merged commit 3c359be into apache:master Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement size_hint and ExactSizedIterator for DecimalArray
4 participants