Helper function used by Decimal128::FromBigEndian
| 1089 | |
| 1090 | // Helper function used by Decimal128::FromBigEndian |
| 1091 | static inline uint64_t UInt64FromBigEndian(const uint8_t* bytes, int32_t length) { |
| 1092 | // We don't bounds check the length here because this is called by |
| 1093 | // FromBigEndian that has a Decimal128 as its out parameters and |
| 1094 | // that function is already checking the length of the bytes and only |
| 1095 | // passes lengths between zero and eight. |
| 1096 | uint64_t result = 0; |
| 1097 | // Using memcpy instead of special casing for length |
| 1098 | // and doing the conversion in 16, 32 parts, which could |
| 1099 | // possibly create unaligned memory access on certain platforms |
| 1100 | memcpy(reinterpret_cast<uint8_t*>(&result) + 8 - length, bytes, length); |
| 1101 | return ::arrow::bit_util::FromBigEndian(result); |
| 1102 | } |
| 1103 | |
| 1104 | Result<Decimal32> Decimal32::FromBigEndian(const uint8_t* bytes, int32_t length) { |
| 1105 | static constexpr int32_t kMinDecimalBytes = 1; |
no test coverage detected