cyb70289 commented on a change in pull request #10651:
URL: https://github.com/apache/arrow/pull/10651#discussion_r674660868
##########
File path: cpp/src/arrow/util/endian.h
##########
@@ -169,13 +205,47 @@ static inline T FromBigEndian(T value) {
return value;
}
+template <typename T, size_t N>
+static inline std::array<T, N> FromBigEndian(std::array<T, N> array) {
+ return array;
+}
+
template <typename T, typename = internal::EnableIfIsOneOf<
T, int64_t, uint64_t, int32_t, uint32_t, int16_t,
uint16_t,
uint8_t, int8_t, float, double>>
static inline T FromLittleEndian(T value) {
return ByteSwap(value);
}
+
+template <typename T, size_t N>
+static inline std::array<T, N> FromLittleEndian(std::array<T, N> array) {
+ std::reverse(array.begin(), array.end());
+ return array;
+}
#endif
+// Read a native endian array as little endian
+template <typename T, size_t N>
+struct LittleEndianArrayReader {
Review comment:
Looks not easy to combine the Reader and Writer classes. Writer can do
both reading and writing, it accepts a pointer. Reader accepts const reference.
The `const T& operator []` is hard to merge.
I added a LittleEndianArray namespace and moved everything in. Export only
`Make` function to construct Reader or Writer per input type.
--
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]