Decode a little-endian 96-bit FLBA(12) TIMESTAMP value into a 64-bit Arrow timestamp. Values that do not fit in the int64 range either error or clamp to the minimum or maximum int64 value, depending on clamp_on_overflow.
| 858 | // Values that do not fit in the int64 range either error or clamp to the minimum or |
| 859 | // maximum int64 value, depending on clamp_on_overflow. |
| 860 | inline Result<int64_t> FlbaTimestampToInt64(const uint8_t* bytes, |
| 861 | bool clamp_on_overflow) { |
| 862 | const uint64_t low = bit_util::FromLittleEndian(SafeLoadAs<uint64_t>(bytes)); |
| 863 | const uint32_t high = bit_util::FromLittleEndian(SafeLoadAs<uint32_t>(bytes + 8)); |
| 864 | const int32_t high_signed = static_cast<int32_t>(high); |
| 865 | const int64_t low_signed = static_cast<int64_t>(low); |
| 866 | const int32_t sign_extension = (low_signed < 0) ? -1 : 0; |
| 867 | // Fits in int64 iff the high part is a pure sign-extension of the low part. |
| 868 | if (ARROW_PREDICT_FALSE(high_signed != sign_extension)) { |
| 869 | if (!clamp_on_overflow) { |
| 870 | return Status::Invalid( |
| 871 | "FLBA(12) TIMESTAMP value does not fit in a 64-bit Arrow timestamp"); |
| 872 | } |
| 873 | return high_signed < 0 ? std::numeric_limits<int64_t>::min() |
| 874 | : std::numeric_limits<int64_t>::max(); |
| 875 | } |
| 876 | return low_signed; |
| 877 | } |
| 878 | |
| 879 | // Read a TIMESTAMP-annotated FLBA(12) column as a 64-bit Arrow timestamp. |
| 880 | Result<Datum> TransferFlbaTimestamp(RecordReader* reader, MemoryPool* pool, |
no test coverage detected