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

Use Fixed-Length Array in BasicDecimal new and raw_value #2405

Merged
merged 2 commits into from Aug 12, 2022

Conversation

HaoYang670
Copy link
Contributor

@HaoYang670 HaoYang670 commented Aug 11, 2022

Signed-off-by: remzi 13716567376yh@gmail.com

Which issue does this PR close?

None.

Rationale for this change

fn Decimal:new and fn Decimal:try_new_bytes should have same API.

What changes are included in this PR?

Add length bound for Decimal:new and Decimal::raw_value.
Update docs

Are there any user-facing changes?

Yes.

Signed-off-by: remzi <13716567376yh@gmail.com>
@github-actions github-actions bot added the arrow Changes to the arrow crate label Aug 11, 2022
Signed-off-by: remzi <13716567376yh@gmail.com>
@HaoYang670 HaoYang670 changed the title Make the API of fn Decimal:new be consistent with fn Decimal:try_new_bytes Make the API of fn Decimal:new be consistent with fn Decimal:try_new_bytes and add length bound for Decimal::raw_value Aug 11, 2022
@@ -123,6 +123,8 @@ impl<const BYTE_WIDTH: usize> BasicDecimalArray<BYTE_WIDTH> {
self.raw_value_data_ptr().offset(pos as isize),
Self::VALUE_LENGTH as usize,
)
.try_into()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any impaction for performance?
Iter the decimalarray will call value_unchecked function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess there is no performance regression. I just move the try_into outside the fn Decimal::new().

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I will cp this commit to my benchmark branch #2360 and test it.

/// Use `try_new_from_bytes` for safe constructor.
pub fn new(precision: usize, scale: usize, bytes: &[u8]) -> Self {
pub fn new(precision: usize, scale: usize, bytes: &[u8; BYTE_WIDTH]) -> Self {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if we should mark this as an unsafe function.

Copy link
Contributor

Choose a reason for hiding this comment

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

From the discussion #2387, we have not come to a consistent conclusion. It better not to change the API?
Do you agree that?

@HaoYang670
Copy link
Contributor Author

Could we merge this PR @liukun4515 @tustvold ?

@tustvold tustvold added the api-change Changes to the arrow API label Aug 12, 2022
Copy link
Contributor

@liukun4515 liukun4515 left a comment

Choose a reason for hiding this comment

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

LGTM

@tustvold tustvold merged commit 0c3c686 into apache:master Aug 12, 2022
@tustvold
Copy link
Contributor

@HaoYang670 I think this had a logical merge conflict - would you mind fixing please 🙏 - https://github.com/apache/arrow-rs/runs/7806676366?check_suite_focus=true

@ursabot
Copy link

ursabot commented Aug 12, 2022

Benchmark runs are scheduled for baseline = 0e97491 and contender = 0c3c686. 0c3c686 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@HaoYang670
Copy link
Contributor Author

Will file a PR to fix this. Wait me ~10 min. Thx.

@HaoYang670
Copy link
Contributor Author

Filed #2432.

@HaoYang670 HaoYang670 deleted the decimal_add_bound branch August 12, 2022 13:42
@tustvold tustvold changed the title Make the API of fn Decimal:new be consistent with fn Decimal:try_new_bytes and add length bound for Decimal::raw_value Use Fixed-Length Array in BasicDecimal new and raw_value Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change Changes to the arrow API arrow Changes to the arrow crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants