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

Method FromBigEndian

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

Source from the content-addressed store, hash-verified

1102}
1103
1104Result<Decimal32> Decimal32::FromBigEndian(const uint8_t* bytes, int32_t length) {
1105 static constexpr int32_t kMinDecimalBytes = 1;
1106 static constexpr int32_t kMaxDecimalBytes = 4;
1107
1108 if (ARROW_PREDICT_FALSE(length < kMinDecimalBytes || length > kMaxDecimalBytes)) {
1109 return Status::Invalid("Length of byte array passed to Decimal32::FromBigEndian was ",
1110 length, ", but must be between ", kMinDecimalBytes, " and ",
1111 kMaxDecimalBytes);
1112 }
1113
1114 const bool is_negative = static_cast<int8_t>(bytes[0]) < 0;
1115 int32_t result = is_negative ? 0xffffffff : 0;
1116 memcpy(reinterpret_cast<uint8_t*>(&result) + kMaxDecimalBytes - length, bytes, length);
1117
1118 const auto value = bit_util::FromBigEndian(result);
1119 return Decimal32(value);
1120}
1121
1122ARROW_EXPORT std::ostream& operator<<(std::ostream& os, const Decimal32& decimal) {
1123 os << decimal.ToIntegerString();

Callers

nothing calls this directly

Calls 9

UInt64FromBigEndianFunction · 0.85
SafeLeftShiftFunction · 0.85
ToNativeFunction · 0.85
FromBigEndianFunction · 0.70
Decimal32Function · 0.70
Decimal64Function · 0.70
Decimal128Function · 0.70
Decimal256Function · 0.70
InvalidFunction · 0.50

Tested by

no test coverage detected