Vishwanatha-HD commented on code in PR #48205:
URL: https://github.com/apache/arrow/pull/48205#discussion_r2599921254
##########
cpp/src/parquet/column_writer.cc:
##########
@@ -2578,13 +2579,31 @@ struct SerializeFunctor<
if constexpr (std::is_same_v<ArrowType, ::arrow::Decimal64Type>) {
*p++ = ::arrow::bit_util::ToBigEndian(u64_in[0]);
} else if constexpr (std::is_same_v<ArrowType, ::arrow::Decimal128Type>)
{
+#if ARROW_LITTLE_ENDIAN
Review Comment:
@pitrou.. I can come up with an optimized logic as below.. Please let me
know if you are fine with it..
FixedLenByteArray FixDecimalEndianness(const uint8_t* in, int64_t offset) {
auto out = reinterpret_cast<const uint8_t*>(scratch) + offset;
constexpr int32_t kSize =
std::is_same_v<ArrowType, ::arrow::Decimal32Type> ? 4 :
std::is_same_v<ArrowType, ::arrow::Decimal64Type> ? 8 :
std::is_same_v<ArrowType, ::arrow::Decimal128Type> ? 16 :
std::is_same_v<ArrowType, ::arrow::Decimal256Type> ? 32 :
0;
static_assert(kSize != 0, "Unsupported decimal type");
uint8_t* out_bytes = reinterpret_cast<uint8_t*>(scratch);
// Arrow guarantees: ByteSwapBuffer swaps only on little-endian.
// On big-endian it becomes memcpy.
::arrow::bit_util::ByteSwapBuffer(out_bytes, in, kSize);
scratch += kSize;
return FixedLenByteArray(out);
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]