-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-12814: [C++][Gandiva] Implements ABS, FLOOR, PI, SQRT, SIGN, LSHIFT, RSHIFT, CEIL, TRUNC, LN and LOG2 functions #10350
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
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 am curious whether all platforms can convert 64-bit integer to long double without loss of digits. (i.e. size(long double) > size(int64)).
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.
@kiszk I checked that by the IEE-754 convention, the numbers in double precision should use at least 8 bytes to construct their representation, so I think that there would not have any digit loss in conversion.
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.
Can we ensure that the same semantics (shift logical or shift arithmetic) on all platforms using just >>?
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.
@kiszk Thanks for your revision, I checked the C++ reference, and I noticed that the shift operators have undefined or implementation-choice behavior for signed and negative numbers.
So as in this Pull Request, we are implementing the Arithmetical Shift, we can cast the input parameters to their respective unsigned types and then apply the shift operators and they will have the same behavior in all platforms. Do you agree with the solution?
|
#10274 handles abs operation well. |
70399da to
124a58d
Compare
|
I included the |
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.
Does it mean that we will accept the loss of digits in INT64?
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.
@kiszk Thanks for your revision! Please, could you explain how would occur digit loss here? I did not understand what you said.
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.
Sorry, I thought the previous version of abs is to cast int64 to double long. But, now, gdv_fn_abs_int64 handles as int64. Correct?
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.
6b7a038 to
1b0747b
Compare
|
@kiszk I applied all suggestions you proposed, could you check if the corrections are fine? Thanks in advance for the review! |
198a993 to
aeea171
Compare
aeea171 to
5d186be
Compare
9d4f95c to
1ac8f04
Compare
1ac8f04 to
a1f2aad
Compare
|
The |
a1f2aad to
098861c
Compare
|
The |
33e97d9 to
c242520
Compare
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 did you choose this threshold? On fabs documentation it uses 6 places for decimal part, shouldn't it be 0.000005 a better value for AlmostEquals threshold?
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 choosing an adequate does not have a simple and unique answer like is shown in these articles:
- https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html
- https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
I choose that number because it is the value defined in the float header as default threshold . For huge and small numbers, I think the developer should set the threshold manually when he is calling the method.
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 will change the method to use the FLT_EPSILON from the macro
9173083 to
848fe4e
Compare
848fe4e to
0a521ef
Compare
|
@kiszk I applied all suggestions you made in the PR. Could you take another look at the PR and see if it is ready to be merged? |
0a521ef to
7c74202
Compare
7c74202 to
a66a367
Compare
|
Sorry for late review. It looks good to me. I would like to ask another review. |
a66a367 to
b94b1a1
Compare
b94b1a1 to
cc0e9fa
Compare
|
ping @pitrou |
e6a1c05 to
cb9ce06
Compare
cb9ce06 to
59778bf
Compare
|
@pitrou can you take a look at this PR? Because I want to close it as soon as possible |
|
@pitrou can you take a look at it? |
|
I would rather if a Gandiva developer vetted this PR. @pravindra perhaps? |
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.
What should happen if there is overflow?
overflow is an in-out parameter.. for some of the later calls overflow could be false - will that cause an issue?
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.
@vvellanki I add a check for that case and it will throw an error if that situation occurs, check that commit: d25a630
59778bf to
879a346
Compare
d25a630 to
9f450bf
Compare
|
Closing because it has been untouched for a while, in case it's still relevant feel free to reopen and move it forward 👍 |
Implements the
ABS,FLOOR,PI,SQRT,SIGN,LSHIFT,RSHIFT,CEILandTRUNC.The RANDOM functions are already implemented in Gandiva.