Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
55011be
Add ByteSwap for 8-bit and floating point
kiszk Jun 21, 2020
2a9178b
add endianness flag to arrow::schema
kiszk Jun 21, 2020
3c15729
fix test failure
kiszk Jul 13, 2020
e3902e6
add missing types of functions to convert endianness
kiszk Jul 19, 2020
e78bbb9
support to convert endian of each element of primitive types if the e…
kiszk Jul 19, 2020
db60ec5
fix lint errors
kiszk Jul 19, 2020
4d5e4c2
fix test failures
kiszk Jul 19, 2020
8735963
fix lint error
kiszk Jul 19, 2020
37518a1
fix compilation error with gcc
kiszk Jul 19, 2020
1d6e78e
fix lint errors
kiszk Jul 19, 2020
af79bbf
revert change in Schema.ToString
kiszk Jul 19, 2020
2c20ef7
support to convert endian of each element for all types
kiszk Jul 26, 2020
469f683
fix build errors
kiszk Jul 26, 2020
094626d
add be/le tests into integration
kiszk Jul 29, 2020
98d5d25
do integration test for endianness with only cpp
kiszk Aug 1, 2020
dc2c578
add a script to generate test files for endian test
kiszk Aug 2, 2020
492a261
fix lint error
kiszk Aug 2, 2020
e40796b
address review comments
kiszk Aug 4, 2020
f2cfe02
fix lint errors
kiszk Aug 4, 2020
7609cd8
define Endianness::NATIVE
kiszk Aug 5, 2020
5857780
fix failure when execute arrow-stream-to-file
kiszk Aug 6, 2020
d198968
fix failure when execute arrow-stream-to-file
kiszk Aug 6, 2020
aa26fdc
address review comments
kiszk Aug 10, 2020
0995889
add endian.h
kiszk Aug 10, 2020
220cee4
fix compilation error when adding endian.h
kiszk Aug 10, 2020
64f0eed
fix lint error
kiszk Aug 10, 2020
794cfee
add endian.h to files where ARROW_..._ENDIAN macro is used
kiszk Aug 10, 2020
d8e0c1c
add endian.h to files where ARROW_..._ENDIAN macro is used
kiszk Aug 11, 2020
e1db096
rename use_native_endian to ensure_native_endian
kiszk Aug 11, 2020
ce4bcee
add comment to ensure_use_native
kiszk Aug 11, 2020
ba2adc0
address review comment
kiszk Aug 11, 2020
3759140
fix lint error
kiszk Aug 11, 2020
61ef770
reallocate buffer when endian is swapped
kiszk Aug 19, 2020
550a13e
address review comment
kiszk Aug 25, 2020
5b1cc4b
fix typo
kiszk Aug 26, 2020
a7ed3c6
swap endian in dictionary if necessary
kiszk Sep 10, 2020
9dc999b
fix build failure
kiszk Sep 23, 2020
62bc52d
fix compilation error
kiszk Oct 6, 2020
6bce03e
initial support Decimal256
kiszk Oct 24, 2020
c57dc22
refactor updating schema
kiszk Nov 11, 2020
689e1b3
address review comments
kiszk Dec 8, 2020
2817d00
add a header file
kiszk Dec 8, 2020
b71868a
fix compilation error
kiszk Dec 8, 2020
ad7dc09
fix test failure in fuzzing
kiszk Dec 9, 2020
ce28dc2
fix test failure in fuzzing
kiszk Dec 19, 2020
3c08285
update arguments
kiszk Dec 19, 2020
ce1929b
fix lint error
kiszk Dec 19, 2020
1d95fd2
Allocate Buffer when data is swapped
kiszk Dec 20, 2020
b29815b
fix test failure in fuzzing
kiszk Dec 20, 2020
bb85b32
address review comments
kiszk Feb 7, 2021
87ab14a
add missing file
kiszk Feb 7, 2021
fb2e041
address review comment
kiszk Feb 14, 2021
3c43047
add test cases for SwapEndianArrayData
kiszk Feb 14, 2021
a9be933
add usage
kiszk Feb 14, 2021
8b7593f
fix compilation error
kiszk Feb 14, 2021
5dd00d3
fix lint error
kiszk Feb 15, 2021
39c55d9
fix compilation error
kiszk Feb 15, 2021
a42b4dc
fix directory path
kiszk Feb 15, 2021
ccb395e
address review comments
kiszk Feb 17, 2021
0cd7468
avoid to run archery integration twice
kiszk Feb 17, 2021
5d7a4b1
update IpcReadContext
kiszk Feb 17, 2021
bcf5bdb
Minor fixes and improvements
pitrou Feb 17, 2021
252a080
Add endianness conversion to feature matrix
pitrou Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/scripts/integration_arrow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ pip install -e $arrow_dir/dev/archery
archery integration --with-all --run-flight \
--gold-dirs=$gold_dir/0.14.1 \
--gold-dirs=$gold_dir/0.17.1 \
--gold-dirs=$gold_dir/1.0.0-bigendian \
--gold-dirs=$gold_dir/1.0.0-littleendian \
--gold-dirs=$gold_dir/2.0.0-compression \
347 changes: 347 additions & 0 deletions cpp/src/arrow/array/array_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include "arrow/result.h"
#include "arrow/scalar.h"
#include "arrow/status.h"
#include "arrow/testing/extension_type.h"
#include "arrow/testing/gtest_common.h"
#include "arrow/testing/gtest_compat.h"
#include "arrow/testing/gtest_util.h"
Expand Down Expand Up @@ -2598,4 +2599,350 @@ TEST(TestRechunkArraysConsistently, Plain) {
}
}

// ----------------------------------------------------------------------
// Test SwapEndianArrayData

/// \brief Indicate if fields are equals.
///
/// \param[in] target ArrayData to be converted and tested
/// \param[in] expected result ArrayData
void AssertArrayDataEqualsWithSwapEndian(const std::shared_ptr<ArrayData>& target,
const std::shared_ptr<ArrayData>& expected) {
auto swap_array = MakeArray(*::arrow::internal::SwapEndianArrayData(target));
auto expected_array = MakeArray(expected);
ASSERT_ARRAYS_EQUAL(*swap_array, *expected_array);
ASSERT_OK(swap_array->ValidateFull());
}

TEST(TestSwapEndianArrayData, PrimitiveType) {
auto null_buffer = Buffer::FromString("\xff");
auto data_int_buffer = Buffer::FromString("01234567");

auto data = ArrayData::Make(null(), 0, {nullptr}, 0);
auto expected_data = data;
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(boolean(), 8, {null_buffer, data_int_buffer}, 0);
expected_data = data;
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(int8(), 8, {null_buffer, data_int_buffer}, 0);
expected_data = data;
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(uint16(), 4, {null_buffer, data_int_buffer}, 0);
auto data_int16_buffer = Buffer::FromString("10325476");
expected_data = ArrayData::Make(uint16(), 4, {null_buffer, data_int16_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(int32(), 2, {null_buffer, data_int_buffer}, 0);
auto data_int32_buffer = Buffer::FromString("32107654");
expected_data = ArrayData::Make(int32(), 2, {null_buffer, data_int32_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(uint64(), 1, {null_buffer, data_int_buffer}, 0);
auto data_int64_buffer = Buffer::FromString("76543210");
expected_data = ArrayData::Make(uint64(), 1, {null_buffer, data_int64_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

auto data_16byte_buffer = Buffer::FromString("0123456789abcdef");
data = ArrayData::Make(decimal128(38, 10), 1, {null_buffer, data_16byte_buffer});
auto data_decimal128_buffer = Buffer::FromString("fedcba9876543210");
expected_data =
ArrayData::Make(decimal128(38, 10), 1, {null_buffer, data_decimal128_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

auto data_32byte_buffer = Buffer::FromString("0123456789abcdef123456789ABCDEF0");
data = ArrayData::Make(decimal256(76, 20), 1, {null_buffer, data_32byte_buffer});
auto data_decimal256_buffer = Buffer::FromString("0FEDCBA987654321fedcba9876543210");
expected_data =
ArrayData::Make(decimal256(76, 20), 1, {null_buffer, data_decimal256_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

auto data_float_buffer = Buffer::FromString("01200560");
data = ArrayData::Make(float32(), 2, {null_buffer, data_float_buffer}, 0);
auto data_float32_buffer = Buffer::FromString("02100650");
expected_data = ArrayData::Make(float32(), 2, {null_buffer, data_float32_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

data = ArrayData::Make(float64(), 1, {null_buffer, data_float_buffer});
auto data_float64_buffer = Buffer::FromString("06500210");
expected_data = ArrayData::Make(float64(), 1, {null_buffer, data_float64_buffer}, 0);
AssertArrayDataEqualsWithSwapEndian(data, expected_data);

// With offset > 0
data =
ArrayData::Make(int64(), 1, {null_buffer, data_int_buffer}, kUnknownNullCount, 1);
ASSERT_RAISES(Invalid, ::arrow::internal::SwapEndianArrayData(data));
}

std::shared_ptr<ArrayData> ReplaceBuffers(const std::shared_ptr<ArrayData>& data,
const int32_t buffer_index,
const std::vector<uint8_t>& buffer_data) {
const auto test_data = data->Copy();
test_data->buffers[buffer_index] =
std::make_shared<Buffer>(buffer_data.data(), buffer_data.size());
return test_data;
}

std::shared_ptr<ArrayData> ReplaceBuffersInChild(const std::shared_ptr<ArrayData>& data,
const int32_t child_index,
const std::vector<uint8_t>& child_data) {
const auto test_data = data->Copy();
// assume updating only buffer[1] in child_data
auto child_array_data = test_data->child_data[child_index]->Copy();
child_array_data->buffers[1] =
std::make_shared<Buffer>(child_data.data(), child_data.size());
test_data->child_data[child_index] = child_array_data;
return test_data;
}

std::shared_ptr<ArrayData> ReplaceBuffersInDictionary(
const std::shared_ptr<ArrayData>& data, const int32_t buffer_index,
const std::vector<uint8_t>& buffer_data) {
const auto test_data = data->Copy();
auto dict_array_data = test_data->dictionary->Copy();
dict_array_data->buffers[buffer_index] =
std::make_shared<Buffer>(buffer_data.data(), buffer_data.size());
test_data->dictionary = dict_array_data;
return test_data;
}

TEST(TestSwapEndianArrayData, BinaryType) {
auto array = ArrayFromJSON(binary(), R"(["0123", null, "45"])");
const std::vector<uint8_t> offset1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6};
#else
{0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, 0};
#endif
auto expected_data = array->data();
auto test_data = ReplaceBuffers(expected_data, 1, offset1);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

array = ArrayFromJSON(large_binary(), R"(["01234", null, "567"])");
const std::vector<uint8_t> offset2 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 8};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
#endif
expected_data = array->data();
test_data = ReplaceBuffers(expected_data, 1, offset2);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

array = ArrayFromJSON(fixed_size_binary(3), R"(["012", null, "345"])");
expected_data = array->data();
AssertArrayDataEqualsWithSwapEndian(expected_data, expected_data);
}

TEST(TestSwapEndianArrayData, StringType) {
auto array = ArrayFromJSON(utf8(), R"(["ABCD", null, "EF"])");
const std::vector<uint8_t> offset1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6};
#else
{0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, 0};
#endif
auto expected_data = array->data();
auto test_data = ReplaceBuffers(expected_data, 1, offset1);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

array = ArrayFromJSON(large_utf8(), R"(["ABCDE", null, "FGH"])");
const std::vector<uint8_t> offset2 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5,
0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 8};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
#endif
expected_data = array->data();
test_data = ReplaceBuffers(expected_data, 1, offset2);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

TEST(TestSwapEndianArrayData, ListType) {
auto type1 = std::make_shared<ListType>(int32());
auto array = ArrayFromJSON(type1, "[[0, 1, 2, 3], null, [4, 5]]");
const std::vector<uint8_t> offset1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6};
#else
{0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, 0};
#endif
const std::vector<uint8_t> data1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5};
#else
{0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0};
#endif
auto expected_data = array->data();
auto test_data = ReplaceBuffers(expected_data, 1, offset1);
test_data = ReplaceBuffersInChild(test_data, 0, data1);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

auto type2 = std::make_shared<LargeListType>(int64());
array = ArrayFromJSON(type2, "[[0, 1, 2], null, [3]]");
const std::vector<uint8_t> offset2 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,
0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0};
#endif
const std::vector<uint8_t> data2 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0};
#endif
expected_data = array->data();
test_data = ReplaceBuffers(expected_data, 1, offset2);
test_data = ReplaceBuffersInChild(test_data, 0, data2);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

auto type3 = std::make_shared<FixedSizeListType>(int32(), 2);
array = ArrayFromJSON(type3, "[[0, 1], null, [2, 3]]");
expected_data = array->data();
const std::vector<uint8_t> data3 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3};
#else
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0};
#endif
test_data = ReplaceBuffersInChild(expected_data, 0, data3);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

TEST(TestSwapEndianArrayData, DictionaryType) {
auto type = dictionary(int32(), int16());
auto dict = ArrayFromJSON(int16(), "[4, 5, 6, 7]");
DictionaryArray array(type, ArrayFromJSON(int32(), "[0, 2, 3]"), dict);
auto expected_data = array.data();
const std::vector<uint8_t> data1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 3};
#else
{0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0};
#endif
const std::vector<uint8_t> data2 =
#if ARROW_LITTLE_ENDIAN
{0, 4, 0, 5, 0, 6, 0, 7};
#else
{4, 0, 5, 0, 6, 0, 7, 0};
#endif
auto test_data = ReplaceBuffers(expected_data, 1, data1);
test_data = ReplaceBuffersInDictionary(test_data, 1, data2);
// dictionary must be explicitly swapped
test_data->dictionary = *::arrow::internal::SwapEndianArrayData(test_data->dictionary);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

TEST(TestSwapEndianArrayData, StructType) {
auto array = ArrayFromJSON(struct_({field("a", int32()), field("b", utf8())}),
R"([{"a": 4, "b": null}, {"a": null, "b": "foo"}])");
auto expected_data = array->data();
const std::vector<uint8_t> data1 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 4, 0, 0, 0, 0};
#else
{4, 0, 0, 0, 0, 0, 0, 0};
#endif
const std::vector<uint8_t> data2 =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0};
#endif
auto test_data = ReplaceBuffersInChild(expected_data, 0, data1);
test_data = ReplaceBuffersInChild(test_data, 1, data2);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

TEST(TestSwapEndianArrayData, UnionType) {
auto expected_i8 = ArrayFromJSON(int8(), "[127, null, null, null, null]");
auto expected_str = ArrayFromJSON(utf8(), R"([null, "abcd", null, null, ""])");
auto expected_i32 = ArrayFromJSON(int32(), "[null, null, 1, 2, null]");
std::vector<uint8_t> expected_types_vector;
expected_types_vector.push_back(Type::INT8);
expected_types_vector.insert(expected_types_vector.end(), 2, Type::STRING);
expected_types_vector.insert(expected_types_vector.end(), 2, Type::INT32);
std::shared_ptr<Array> expected_types;
ArrayFromVector<Int8Type, uint8_t>(expected_types_vector, &expected_types);
auto arr1 = SparseUnionArray::Make(
*expected_types, {expected_i8, expected_str, expected_i32}, {"i8", "str", "i32"},
{Type::INT8, Type::STRING, Type::INT32});
auto expected_data = (*arr1)->data();
const std::vector<uint8_t> data1a =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0};
#endif
const std::vector<uint8_t> data1b =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0};
#endif
auto test_data = ReplaceBuffersInChild(expected_data, 1, data1a);
test_data = ReplaceBuffersInChild(test_data, 2, data1b);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);

expected_i8 = ArrayFromJSON(int8(), "[33, 10, -10]");
expected_str = ArrayFromJSON(utf8(), R"(["abc", "", "def"])");
expected_i32 = ArrayFromJSON(int32(), "[1, -259, 2]");
auto expected_offsets = ArrayFromJSON(int32(), "[0, 0, 0, 1, 1, 1, 2, 2, 2]");
auto arr2 = DenseUnionArray::Make(
*expected_types, *expected_offsets, {expected_i8, expected_str, expected_i32},
{"i8", "str", "i32"}, {Type::INT8, Type::STRING, Type::INT32});
expected_data = (*arr2)->data();
const std::vector<uint8_t> data2a =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2};
#else
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0};
#endif
const std::vector<uint8_t> data2b =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 6};
#else
{0, 0, 0, 0, 3, 0, 0, 0, 3, 0, 0, 0, 6, 0, 0, 0};
#endif
const std::vector<uint8_t> data2c =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 1, 255, 255, 254, 253, 0, 0, 0, 2};
#else
{1, 0, 0, 0, 253, 254, 255, 255, 2, 0, 0, 0};
#endif
test_data = ReplaceBuffers(expected_data, 2, data2a);
test_data = ReplaceBuffersInChild(test_data, 1, data2b);
test_data = ReplaceBuffersInChild(test_data, 2, data2c);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

TEST(TestSwapEndianArrayData, ExtensionType) {
auto array_int16 = ArrayFromJSON(int16(), "[0, 1, 2, 3]");
auto ext_data = array_int16->data()->Copy();
ext_data->type = std::make_shared<SmallintType>();
auto array = MakeArray(ext_data);
auto expected_data = array->data();
const std::vector<uint8_t> data =
#if ARROW_LITTLE_ENDIAN
{0, 0, 0, 1, 0, 2, 0, 3};
#else
{0, 0, 1, 0, 2, 0, 3, 0};
#endif
auto test_data = ReplaceBuffers(expected_data, 1, data);
AssertArrayDataEqualsWithSwapEndian(test_data, expected_data);
}

} // namespace arrow
2 changes: 1 addition & 1 deletion cpp/src/arrow/array/array_view_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "arrow/status.h"
#include "arrow/testing/gtest_util.h"
#include "arrow/type.h"
#include "arrow/util/bit_util.h"
#include "arrow/util/endian.h"
#include "arrow/util/logging.h"

namespace arrow {
Expand Down
Loading