From 80d031fe33fca378223efab6ce382d34a50ffdf5 Mon Sep 17 00:00:00 2001 From: Kazuaki Ishizaki Date: Sat, 9 May 2020 15:59:19 -0500 Subject: [PATCH] ARROW-8747: [C++] Write compressed size in little-endian format for Feather V2 This PR always puts the compressed size in little-endian format for Feather V2 since the reader expected the little-endian format. Based on [the discussion](https://github.com/apache/arrow/pull/6777#discussion_r400770040) at #6777, [this commit](https://github.com/apache/arrow/pull/6777/commits/aa282801e18c2f13a145390ae3b42be23578a2d8) reads compressed_length in Feather V2 format as little-endian. However, the writer [puts compressed_length in native-endian](https://github.com/apache/arrow/blob/master/cpp/src/arrow/ipc/writer.cc#L177). This PR can fix failures related to reading compressed feather format in `arrow-ipc-read-write-test` and `arrow-feather-test`. Closes #7137 from kiszk/ARROW-8747 Authored-by: Kazuaki Ishizaki Signed-off-by: Wes McKinney --- cpp/src/arrow/ipc/writer.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/src/arrow/ipc/writer.cc b/cpp/src/arrow/ipc/writer.cc index 4adfe8ab5e927..fd0c9bc8474e6 100644 --- a/cpp/src/arrow/ipc/writer.cc +++ b/cpp/src/arrow/ipc/writer.cc @@ -174,7 +174,8 @@ class RecordBatchSerializer { ARROW_ASSIGN_OR_RAISE(actual_length, codec->Compress(buffer.size(), buffer.data(), maximum_length, result->mutable_data() + sizeof(int64_t))); - *reinterpret_cast(result->mutable_data()) = buffer.size(); + *reinterpret_cast(result->mutable_data()) = + BitUtil::ToLittleEndian(buffer.size()); *out = SliceBuffer(std::move(result), /*offset=*/0, actual_length + sizeof(int64_t)); return Status::OK(); }