Skip to content

Commit

Permalink
Use std::vector instead of manual built arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
raulcd committed Nov 21, 2024
1 parent 999dcee commit 9ece78f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions cpp/src/arrow/array/array_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,9 +1186,8 @@ TEST_F(TestMapArray, BuildingStringToInt) {
std::vector<int32_t> offsets = {0, 2, 2, 3, 3};
auto expected_keys = ArrayFromJSON(utf8(), R"(["joe", "mark", "cap"])");
auto expected_values = ArrayFromJSON(int32(), "[0, null, 8]");
uint8_t bitmap_bytes[] = {1, 0, 1, 1};
ASSERT_OK_AND_ASSIGN(auto expected_null_bitmap,
internal::BytesToBits(util::span(bitmap_bytes)));
internal::BytesToBits(std::vector<uint8_t>({1, 0, 1, 1})));
MapArray expected(type, 4, Buffer::Wrap(offsets), expected_keys, expected_values,
expected_null_bitmap, 1);

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/arrow/ipc/json_simple_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -857,8 +857,8 @@ TEST(TestMap, StringToInteger) {
ASSERT_OK_AND_ASSIGN(auto expected_keys,
ArrayFromJSON(utf8(), R"(["joe", "mark", "cap"])"));
ASSERT_OK_AND_ASSIGN(auto expected_values, ArrayFromJSON(int32(), "[0, null, 8]"));
uint8_t bitmap_bytes[] = {1, 0, 1, 1};
ASSERT_OK_AND_ASSIGN(auto expected_null_bitmap, BytesToBits(util::span(bitmap_bytes)));
ASSERT_OK_AND_ASSIGN(auto expected_null_bitmap,
BytesToBits(std::vector<uint8_t>({1, 0, 1, 1})));
auto expected =
std::make_shared<MapArray>(type, 4, Buffer::Wrap(offsets), expected_keys,
expected_values, expected_null_bitmap, 1);
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/parquet/column_writer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1001,9 +1001,8 @@ TEST(TestColumnWriter, RepeatedListsUpdateSpacedBug) {
auto values_data = reinterpret_cast<const int32_t*>(values_buffer->data());

std::shared_ptr<Buffer> valid_bits;
uint8_t bitmap_bytes[] = {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1};
ASSERT_OK_AND_ASSIGN(valid_bits,
::arrow::internal::BytesToBits(::arrow::util::span(bitmap_bytes)));
std::vector<uint8_t> bitmap_bytes = {1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1};
ASSERT_OK_AND_ASSIGN(valid_bits, ::arrow::internal::BytesToBits(bitmap_bytes));

// valgrind will warn about out of bounds access into def_levels_data
typed_writer->WriteBatchSpaced(14, def_levels.data(), rep_levels.data(),
Expand Down

0 comments on commit 9ece78f

Please sign in to comment.