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

Function BuildFromArray

cpp/src/arrow/util/basic_decimal.cc:780–801  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778/// \brief Build a native endian array of uint64_t from a big endian array of uint32_t.
779template <size_t N>
780static DecimalStatus BuildFromArray(std::array<uint64_t, N>* result_array,
781 const uint32_t* array, int64_t length) {
782 for (int64_t i = length - 2 * N - 1; i >= 0; i--) {
783 if (array[i] != 0) {
784 return DecimalStatus::kOverflow;
785 }
786 }
787 int64_t next_index = length - 1;
788 size_t i = 0;
789 auto result_array_le = bit_util::little_endian::Make(result_array);
790 for (; i < N && next_index >= 0; i++) {
791 uint64_t lower_bits = array[next_index--];
792 result_array_le[i] =
793 (next_index < 0)
794 ? lower_bits
795 : ((static_cast<uint64_t>(array[next_index--]) << 32) + lower_bits);
796 }
797 for (; i < N; i++) {
798 result_array_le[i] = 0;
799 }
800 return DecimalStatus::kSuccess;
801}
802
803/// \brief Build a BasicDecimal128 from a big endian array of uint32_t.
804static DecimalStatus BuildFromArray(BasicDecimal128* value, const uint32_t* array,

Callers 2

SingleDivideFunction · 0.85
DecimalDivideFunction · 0.85

Calls 2

BasicDecimal256Function · 0.85
MakeFunction · 0.70

Tested by

no test coverage detected