-
Notifications
You must be signed in to change notification settings - Fork 70
feat: add decimal value representation #182
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
70068f9 to
e48c9f8
Compare
|
Could you explicitly mark which part is exactly ported from Arrow to make the current review and future sync process easier? |
That's not easy, Arrow's Decimal type uses a complex inheritance hierarchy and supports bit lengths in any 64-bit multiple. Since we only need Decimal128, l omitted the inheritance layer. But the algorithms adapted from Arrow is quite straightforward and should be easy for future sync. |
|
What about a |
|
I guess we cannot port My concern is that we use |
uint128_t is now used for Decimal multiplier, I think we can use int128_t for the division, let me try the int128_t physical representation idea for the next few days. |
6ab1a93 to
a4b5dde
Compare
2b23ca3 to
bfe9fc1
Compare
|
|
||
| Decimal::Decimal(std::string_view str) { | ||
| auto result = Decimal::FromString(str); | ||
| if (!result) { |
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.
Then please throw IcebergError and add a comment with \throw by recommending Decimal::FromString to be used in production.
9cbc0df to
54b09e7
Compare
54b09e7 to
081ef1f
Compare
|
@mapleFU Can you take a look at this again, thanks. |
|
This is mainly ported from Arrow C++. Could you help take a quick pass? @lidavidm @zeroshade |
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.
This looks good to me @zhjwpku Thanks for working on this, and thanks @wgtmac and @dongxiao1198 for the review 🙌
| uint128_t value = 0; | ||
| ShiftAndAdd(dec.while_digits, value); | ||
| ShiftAndAdd(dec.fractional_digits, value); | ||
| Decimal result(static_cast<int128_t>(value)); |
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.
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.
Thanks for the reminder, will keep in mind, thanks.

No description provided.