felipecrv commented on code in PR #35997:
URL: https://github.com/apache/arrow/pull/35997#discussion_r1223808788
##########
cpp/src/arrow/util/decimal.cc:
##########
@@ -44,195 +45,291 @@ using internal::SafeLeftShift;
using internal::SafeSignedAdd;
using internal::uint128_t;
-Decimal128::Decimal128(const std::string& str) : Decimal128() {
- *this = Decimal128::FromString(str).ValueOrDie();
-}
+namespace {
-static constexpr auto kInt64DecimalDigits =
- static_cast<size_t>(std::numeric_limits<int64_t>::digits10);
-
-static constexpr uint64_t kUInt64PowersOfTen[kInt64DecimalDigits + 1] = {
- // clang-format off
- 1ULL,
- 10ULL,
- 100ULL,
- 1000ULL,
- 10000ULL,
- 100000ULL,
- 1000000ULL,
- 10000000ULL,
- 100000000ULL,
- 1000000000ULL,
- 10000000000ULL,
- 100000000000ULL,
- 1000000000000ULL,
- 10000000000000ULL,
- 100000000000000ULL,
- 1000000000000000ULL,
- 10000000000000000ULL,
- 100000000000000000ULL,
- 1000000000000000000ULL
- // clang-format on
+struct BaseDecimalRealConversion {
+ // Return 10**exp, with a fast lookup, assuming `exp` is withing bounds
Review Comment:
typo: withing -> within
##########
cpp/src/arrow/util/basic_decimal.cc:
##########
@@ -1188,14 +857,14 @@ BasicDecimal256& BasicDecimal256::operator<<=(uint32_t
bits) {
if (bits == 0) {
return *this;
}
- int cross_word_shift = bits / 64;
- if (static_cast<size_t>(cross_word_shift) >= array_.size()) {
+ const int cross_word_shift = bits / 64;
+ if (cross_word_shift >= kWordWidth) {
Review Comment:
`kWordWidth` is the width of the decimal in words, right? Not the width of a
single word. A bit of a confusing name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]