Commits


Kazuaki Ishizaki authored and Krisztián Szűcs committed 1e6cb8b8d48
ARROW-8467: [C++] Fix TestArrayImport tests for big-endian platforms This PR fixes two problems. 1. `DecodeMetadata()` always assume that a length of metadata is stored in a little-endian format. According to [this specification](https://github.com/apache/arrow/blob/master/docs/source/format/CDataInterface.rst#the-arrowschema-structure), the length is stored in a native endianness. This causes the following failure. This PR makes the interpretation of the length correct. ``` 12: [ RUN ] TestSchemaImport.Struct 12: /home/ishizaki/Arrow/arrow/cpp/build-support/run-test.sh: line 92: 19528 Segmentation fault (core dumped) $TEST_EXECUTABLE "$@" 2>&1 12: 19529 Done | $ROOT/build-support/asan_symbolize.py 12: 19530 Done | ${CXXFILT:-c++filt} 12: 19531 Done | $ROOT/build-support/stacktrace_addr2line.pl $TEST_EXECUTABLE 12: 19532 Done | $pipe_cmd 2>&1 12: 19533 Done | tee $LOGFILE ``` 1. `primitive_buffers_...` used in `TestImportArray` implicitly assumes little-endian. The following is an example. ``` static const uint8_t data_buffer1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; static const void* primitive_buffers_no_nulls1[2] = {nullptr, data_buffer1}; ... TEST_F(TestArrayImport, PrimitiveWithOffset) { ... FillPrimitive(3, 0, 1, primitive_buffers_no_nulls1); CheckImport(ArrayFromJSON(uint16(), "[1027, 1541, 2055]")); ``` The above code works since `03 04 05 06 07 08` is interpreted as `0x0403` (=1027), `0x0605` (=1541), and `0x0807` (=2055) on a little-endian platform. It is interpreted as `0x0304`, `0x0506`, and `0x0708` on a big-endian platform. This causes the following failure. The PR prepares `data_buffer` for each type on both endians. ``` 12: [ RUN ] TestArrayImport.PrimitiveWithOffset 12: /home/ishizaki/Arrow/arrow/cpp/src/arrow/testing/gtest_util.cc:77: Failure 12: Failed 12: 12: @@ -0, +0 @@ 12: -1027 12: -1541 12: -2055 12: +772 12: +1286 12: +1800 12: Expected: 12: [ 12: 1027, 12: 1541, 12: 2055 12: ] 12: Actual: 12: [ 12: 772, 12: 1286, 12: 1800 12: ] ``` Closes #6958 from kiszk/SPARK-8484 Authored-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com> Signed-off-by: Antoine Pitrou <antoine@python.org>