pitrou commented on code in PR #48203:
URL: https://github.com/apache/arrow/pull/48203#discussion_r2556422754
##########
cpp/src/parquet/encoder.cc:
##########
@@ -201,7 +202,27 @@ class PlainEncoder : public EncoderImpl, virtual public
TypedEncoder<DType> {
template <typename DType>
void PlainEncoder<DType>::Put(const T* buffer, int num_values) {
if (num_values > 0) {
+#if ARROW_LITTLE_ENDIAN
PARQUET_THROW_NOT_OK(sink_.Append(buffer, num_values * sizeof(T)));
+#else
+ // On big-endian systems, we need to byte-swap each value
+ // since Parquet data must be stored in little-endian format.
+ if constexpr (std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t> ||
+ std::is_same_v<T, int64_t> || std::is_same_v<T, uint64_t> ||
+ std::is_same_v<T, float> || std::is_same_v<T, double>) {
+ PARQUET_ASSIGN_OR_THROW(
+ auto temp_buffer,
+ ::arrow::AllocateBuffer(num_values * sizeof(T),
this->memory_pool()));
Review Comment:
Wow, can you use a small-sized stack-allocated buffer instead? (for example
a `std::array<T, 128>`).
--
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]