MCPcopy Create free account
hub / github.com/apache/arrow / ShiftAndAdd

Function ShiftAndAdd

cpp/src/arrow/util/decimal.cc:771–788  ·  view source on GitHub ↗

Iterates over input and for each group of kInt64DecimalDigits multiple out by the appropriate power of 10 necessary to add source parsed as uint64 and then adds the parsed value of source.

Source from the content-addressed store, hash-verified

769// the appropriate power of 10 necessary to add source parsed as uint64 and
770// then adds the parsed value of source.
771static inline void ShiftAndAdd(std::string_view input, uint64_t out[], size_t out_size) {
772 for (size_t posn = 0; posn < input.size();) {
773 const size_t group_size = std::min(kInt64DecimalDigits, input.size() - posn);
774 const uint64_t multiple = kUInt64PowersOfTen[group_size];
775 uint64_t chunk = 0;
776 ARROW_CHECK(
777 internal::ParseValue<UInt64Type>(input.data() + posn, group_size, &chunk));
778
779 for (size_t i = 0; i < out_size; ++i) {
780 uint128_t tmp = out[i];
781 tmp *= multiple;
782 tmp += chunk;
783 out[i] = static_cast<uint64_t>(tmp & 0xFFFFFFFFFFFFFFFFULL);
784 chunk = static_cast<uint64_t>(tmp >> 64);
785 }
786 posn += group_size;
787 }
788}
789
790namespace {
791

Callers 2

DecimalFromStringFunction · 0.85
SimpleDecimalFromStringFunction · 0.85

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected