Skip to content

Commit

Permalink
Fix debug build errors from to_arrow_device_test.cpp (rapidsai#15463)
Browse files Browse the repository at this point in the history
Fixes debug build failures resulting from changes from rapidsai#15047. Here are some of the errors reported by the compiler:
```
Building CXX object tests/CMakeFiles/INTEROP_TEST.dir/interop/to_arrow_device_test.cpp.o
FAILED: tests/CMakeFiles/INTEROP_TEST.dir/interop/to_arrow_device_test.cpp.o 
/usr/local/bin/g++ -DFMT_HEADER_ONLY=1 -DLIBCUDACXX_ENABLE_EXPERIMENTAL_MEMORY_RESOURCE -DNANOARROW_DEBUG -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO -DSPDLOG_FMT_EXTERNAL -DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA -DTHRUST_DISABLE_ABI_NAMESPACE -DTHRUST_HOST_SYSTEM=THRUST_HOST_SYSTEM_CPP -DTHRUST_IGNORE_ABI_NAMESPACE_ERROR -I/cudf/cpp -I/cudf/cpp/src -I/cudf/cpp/build/_deps/dlpack-src/include -I/cudf/cpp/build/_deps/jitify-src -I/cudf/cpp/include -I/cudf/cpp/build/include -I/cudf/cpp/build/_deps/cccl-src/thrust/thrust/cmake/../.. -I/cudf/cpp/build/_deps/cccl-src/libcudacxx/lib/cmake/libcudacxx/../../../include -I/cudf/cpp/build/_deps/cccl-src/cub/cub/cmake/../.. -I/cudf/cpp/build/_deps/nvtx3-src/c/include -I/cudf/cpp/build/_deps/nanoarrow-src/src -I/cudf/cpp/build/_deps/nanoarrow-build/generated -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /conda/envs/rapids/include -fdiagnostics-color=always  -I/conda/envs/rapids/targets/x86_64-linux/include  -L/conda/envs/rapids/targets/x86_64-linux/lib -L/conda/envs/rapids/targets/x86_64-linux/lib/stubs -g -std=gnu++17 -fPIE -Wall -Werror -Wno-unknown-pragmas -Wno-error=deprecated-declarations -pthread -MD -MT tests/CMakeFiles/INTEROP_TEST.dir/interop/to_arrow_device_test.cpp.o -MF tests/CMakeFiles/INTEROP_TEST.dir/interop/to_arrow_device_test.cpp.o.d -o tests/CMakeFiles/INTEROP_TEST.dir/interop/to_arrow_device_test.cpp.o -c /cudf/cpp/tests/interop/to_arrow_device_test.cpp
In file included from /cudf/cpp/tests/interop/to_arrow_device_test.cpp:17:
/cudf/cpp/tests/interop/nanoarrow_utils.hpp: In function 'void populate_list_from_col(ArrowArray*, cudf::lists_column_view)':
/cudf/cpp/tests/interop/nanoarrow_utils.hpp:220:26: error: ignoring return value of 'ArrowErrorCode ArrowBufferSetAllocator(ArrowBuffer*, ArrowBufferAllocator)' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  220 |   ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc);
      |   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/cudf/cpp/tests/interop/nanoarrow_utils.hpp:224:26: error: ignoring return value of 'ArrowErrorCode ArrowBufferSetAllocator(ArrowBuffer*, ArrowBufferAllocator)' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  224 |   ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc);
      |   ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/cudf/cpp/tests/interop/to_arrow_device_test.cpp: In member function 'void BaseArrowFixture::compare_arrays(const ArrowSchema*, const ArrowArray*, const ArrowArray*)':
/cudf/cpp/tests/interop/to_arrow_device_test.cpp:268:24: error: ignoring return value of 'ArrowErrorCode cudfArrowSchemaViewInit(ArrowSchemaView*, const ArrowSchema*, ArrowError*)' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  268 |     ArrowSchemaViewInit(&schema_view, schema, nullptr);
/cudf/cpp/tests/interop/to_arrow_device_test.cpp: In member function 'virtual void ToArrowDeviceTest_DateTimeTable_Test::TestBody()':
/cudf/cpp/tests/interop/to_arrow_device_test.cpp:353:27: error: ignoring return value of 'ArrowErrorCode cudfArrowSchemaSetTypeStruct(ArrowSchema*, int64_t)' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  353 |   ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
/cudf/cpp/tests/interop/to_arrow_device_test.cpp:355:29: error: ignoring return value of 'ArrowErrorCode cudfArrowSchemaSetTypeDateTime(ArrowSchema*, ArrowType, ArrowTimeUnit, const char*)' declared with attribute 'warn_unused_result' [-Werror=unused-result]

(many more)
```
Warning are turned into errors so the build fails.
Fix simply adds the `NANOARROW_THROW_NOT_OK` to the offending calls.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Vukasin Milovanovic (https://github.com/vuule)
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Mike Wilson (https://github.com/hyperbolic2346)

URL: rapidsai#15463
  • Loading branch information
davidwendt authored Apr 5, 2024
1 parent a00c3c9 commit 9ae32fe
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 72 deletions.
20 changes: 10 additions & 10 deletions cpp/tests/interop/nanoarrow_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ std::enable_if_t<cudf::is_fixed_width<T>() and !std::is_same_v<T, bool>, void> p
{
arr->length = view.size();
arr->null_count = view.null_count();
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc));
ArrowArrayValidityBitmap(arr)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view.null_mask()));
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc));
ArrowArrayBuffer(arr, 1)->data = const_cast<uint8_t*>(view.data<uint8_t>());
}

Expand Down Expand Up @@ -109,20 +109,20 @@ std::enable_if_t<std::is_same_v<T, bool>, void> populate_from_col(ArrowArray* ar
{
arr->length = view.size();
arr->null_count = view.null_count();
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc));
ArrowArrayValidityBitmap(arr)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view.null_mask()));

auto bitmask = cudf::bools_to_mask(view);
auto ptr = reinterpret_cast<uint8_t*>(bitmask.first->data());
ArrowBufferSetAllocator(
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(
ArrowArrayBuffer(arr, 1),
ArrowBufferDeallocator(
[](ArrowBufferAllocator* alloc, uint8_t*, int64_t) {
auto buf = reinterpret_cast<std::unique_ptr<rmm::device_buffer>*>(alloc->private_data);
delete buf;
},
new std::unique_ptr<rmm::device_buffer>(std::move(bitmask.first))));
new std::unique_ptr<rmm::device_buffer>(std::move(bitmask.first)))));
ArrowArrayBuffer(arr, 1)->data = ptr;
}

Expand Down Expand Up @@ -160,14 +160,14 @@ std::enable_if_t<std::is_same_v<T, cudf::string_view>, void> populate_from_col(
{
arr->length = view.size();
arr->null_count = view.null_count();
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc));
ArrowArrayValidityBitmap(arr)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view.null_mask()));

cudf::strings_column_view sview{view};
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc));
ArrowArrayBuffer(arr, 1)->data = const_cast<uint8_t*>(sview.offsets().data<uint8_t>());
ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 2), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 2), noop_alloc));
ArrowArrayBuffer(arr, 2)->data = const_cast<uint8_t*>(view.data<uint8_t>());
}

Expand Down Expand Up @@ -217,10 +217,10 @@ void populate_list_from_col(ArrowArray* arr, cudf::lists_column_view view)
arr->length = view.size();
arr->null_count = view.null_count();

ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 0), noop_alloc));
ArrowArrayValidityBitmap(arr)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view.null_mask()));

ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(arr, 1), noop_alloc));
ArrowArrayBuffer(arr, 1)->data = const_cast<uint8_t*>(view.offsets().data<uint8_t>());
}
140 changes: 78 additions & 62 deletions cpp/tests/interop/to_arrow_device_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ struct BaseArrowFixture : public cudf::test::BaseFixture {
const ArrowArray* actual)
{
ArrowSchemaView schema_view;
ArrowSchemaViewInit(&schema_view, schema, nullptr);
NANOARROW_THROW_NOT_OK(ArrowSchemaViewInit(&schema_view, schema, nullptr));

EXPECT_EQ(expected->length, actual->length);
EXPECT_EQ(expected->null_count, actual->null_count);
Expand Down Expand Up @@ -350,11 +350,11 @@ TEST_F(ToArrowDeviceTest, DateTimeTable)
cudf::to_arrow_schema(input.view(), std::vector<cudf::column_metadata>{{"a"}});
nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));
ArrowSchemaInit(expected_schema->children[0]);
ArrowSchemaSetTypeDateTime(
expected_schema->children[0], NANOARROW_TYPE_TIMESTAMP, NANOARROW_TIME_UNIT_MILLI, nullptr);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeDateTime(
expected_schema->children[0], NANOARROW_TYPE_TIMESTAMP, NANOARROW_TIME_UNIT_MILLI, nullptr));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = 0;

compare_schemas(expected_schema.get(), got_arrow_schema.get());
Expand Down Expand Up @@ -395,7 +395,7 @@ TYPED_TEST(ToArrowDeviceTestDurationsTest, DurationTable)

nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));

ArrowSchemaInit(expected_schema->children[0]);
const ArrowTimeUnit arrow_unit = [&] {
Expand All @@ -407,9 +407,9 @@ TYPED_TEST(ToArrowDeviceTestDurationsTest, DurationTable)
default: CUDF_FAIL("Unsupported duration unit in arrow");
}
}();
ArrowSchemaSetTypeDateTime(
expected_schema->children[0], NANOARROW_TYPE_DURATION, arrow_unit, nullptr);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeDateTime(
expected_schema->children[0], NANOARROW_TYPE_DURATION, arrow_unit, nullptr));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = 0;

auto got_arrow_schema =
Expand Down Expand Up @@ -450,19 +450,22 @@ TEST_F(ToArrowDeviceTest, NestedList)

nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));

ArrowSchemaInitFromType(expected_schema->children[0], NANOARROW_TYPE_LIST);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(expected_schema->children[0], NANOARROW_TYPE_LIST));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = ARROW_FLAG_NULLABLE;

ArrowSchemaInitFromType(expected_schema->children[0]->children[0], NANOARROW_TYPE_LIST);
ArrowSchemaSetName(expected_schema->children[0]->children[0], "element");
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(expected_schema->children[0]->children[0], NANOARROW_TYPE_LIST));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0]->children[0], "element"));
expected_schema->children[0]->children[0]->flags = 0;

ArrowSchemaInitFromType(expected_schema->children[0]->children[0]->children[0],
NANOARROW_TYPE_INT64);
ArrowSchemaSetName(expected_schema->children[0]->children[0]->children[0], "element");
NANOARROW_THROW_NOT_OK(ArrowSchemaInitFromType(
expected_schema->children[0]->children[0]->children[0], NANOARROW_TYPE_INT64));
NANOARROW_THROW_NOT_OK(
ArrowSchemaSetName(expected_schema->children[0]->children[0]->children[0], "element"));
expected_schema->children[0]->children[0]->children[0]->flags = ARROW_FLAG_NULLABLE;

auto got_arrow_schema =
Expand All @@ -481,7 +484,8 @@ TEST_F(ToArrowDeviceTest, NestedList)
populate_list_from_col(top_list->children[0], nested_view);
populate_from_col<int64_t>(top_list->children[0]->children[0], nested_view.child());

ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr));

auto got_arrow_array = cudf::to_arrow_device(std::move(input));
EXPECT_EQ(rmm::get_current_cuda_device().value(), got_arrow_array->device_id);
Expand Down Expand Up @@ -537,52 +541,58 @@ TEST_F(ToArrowDeviceTest, StructColumn)

nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));

ArrowSchemaInit(expected_schema->children[0]);
ArrowSchemaSetTypeStruct(expected_schema->children[0], 5);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema->children[0], 5));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = 0;

auto child = expected_schema->children[0];
ArrowSchemaInitFromType(child->children[0], NANOARROW_TYPE_STRING);
ArrowSchemaSetName(child->children[0], "string");
NANOARROW_THROW_NOT_OK(ArrowSchemaInitFromType(child->children[0], NANOARROW_TYPE_STRING));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[0], "string"));
child->children[0]->flags = 0;

ArrowSchemaInitFromType(child->children[1], NANOARROW_TYPE_INT32);
ArrowSchemaSetName(child->children[1], "integral");
NANOARROW_THROW_NOT_OK(ArrowSchemaInitFromType(child->children[1], NANOARROW_TYPE_INT32));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[1], "integral"));
child->children[1]->flags = 0;

ArrowSchemaInitFromType(child->children[2], NANOARROW_TYPE_BOOL);
ArrowSchemaSetName(child->children[2], "bool");
NANOARROW_THROW_NOT_OK(ArrowSchemaInitFromType(child->children[2], NANOARROW_TYPE_BOOL));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[2], "bool"));
child->children[2]->flags = 0;

ArrowSchemaInitFromType(child->children[3], NANOARROW_TYPE_LIST);
ArrowSchemaSetName(child->children[3], "nested_list");
NANOARROW_THROW_NOT_OK(ArrowSchemaInitFromType(child->children[3], NANOARROW_TYPE_LIST));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[3], "nested_list"));
child->children[3]->flags = 0;
ArrowSchemaInitFromType(child->children[3]->children[0], NANOARROW_TYPE_LIST);
ArrowSchemaSetName(child->children[3]->children[0], "element");
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(child->children[3]->children[0], NANOARROW_TYPE_LIST));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[3]->children[0], "element"));
child->children[3]->children[0]->flags = 0;
ArrowSchemaInitFromType(child->children[3]->children[0]->children[0], NANOARROW_TYPE_INT64);
ArrowSchemaSetName(child->children[3]->children[0]->children[0], "element");
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(child->children[3]->children[0]->children[0], NANOARROW_TYPE_INT64));
NANOARROW_THROW_NOT_OK(
ArrowSchemaSetName(child->children[3]->children[0]->children[0], "element"));
child->children[3]->children[0]->children[0]->flags = 0;

ArrowSchemaInit(child->children[4]);
ArrowSchemaSetTypeStruct(child->children[4], 2);
ArrowSchemaSetName(child->children[4], "struct");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(child->children[4], 2));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[4], "struct"));

ArrowSchemaInitFromType(child->children[4]->children[0], NANOARROW_TYPE_STRING);
ArrowSchemaSetName(child->children[4]->children[0], "string2");
ArrowSchemaInitFromType(child->children[4]->children[1], NANOARROW_TYPE_INT32);
ArrowSchemaSetName(child->children[4]->children[1], "integral2");
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(child->children[4]->children[0], NANOARROW_TYPE_STRING));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[4]->children[0], "string2"));
NANOARROW_THROW_NOT_OK(
ArrowSchemaInitFromType(child->children[4]->children[1], NANOARROW_TYPE_INT32));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(child->children[4]->children[1], "integral2"));

auto got_arrow_schema =
cudf::to_arrow_schema(input.view(), std::vector<cudf::column_metadata>{metadata});
compare_schemas(expected_schema.get(), got_arrow_schema.get());
ArrowSchemaRelease(got_arrow_schema.get());

nanoarrow::UniqueArray expected_array;
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr));

expected_array->length = input.num_rows();

Expand All @@ -591,7 +601,7 @@ TEST_F(ToArrowDeviceTest, StructColumn)
array_a->length = view_a.size();
array_a->null_count = view_a.null_count();

ArrowBufferSetAllocator(ArrowArrayBuffer(array_a, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(array_a, 0), noop_alloc));
ArrowArrayValidityBitmap(array_a)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view_a.null_mask()));

Expand All @@ -609,14 +619,15 @@ TEST_F(ToArrowDeviceTest, StructColumn)
array_struct->length = view_struct.size();
array_struct->null_count = view_struct.null_count();

ArrowBufferSetAllocator(ArrowArrayBuffer(array_struct, 0), noop_alloc);
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(ArrowArrayBuffer(array_struct, 0), noop_alloc));
ArrowArrayValidityBitmap(array_struct)->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(view_struct.null_mask()));

populate_from_col<cudf::string_view>(array_struct->children[0], view_struct.child(0));
populate_from_col<int32_t>(array_struct->children[1], view_struct.child(1));

ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr));

auto got_arrow_array = cudf::to_arrow_device(std::move(input));
EXPECT_EQ(rmm::get_current_cuda_device().value(), got_arrow_array->device_id);
Expand All @@ -642,13 +653,13 @@ TEST_F(ToArrowDeviceTest, FixedPoint64Table)

nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));
ArrowSchemaInit(expected_schema->children[0]);
ArrowSchemaSetTypeDecimal(expected_schema->children[0],
NANOARROW_TYPE_DECIMAL128,
cudf::detail::max_precision<int64_t>(),
-scale);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeDecimal(expected_schema->children[0],
NANOARROW_TYPE_DECIMAL128,
cudf::detail::max_precision<int64_t>(),
-scale));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = 0;

auto got_arrow_schema =
Expand All @@ -665,26 +676,29 @@ TEST_F(ToArrowDeviceTest, FixedPoint64Table)

cudf::get_default_stream().synchronize();
nanoarrow::UniqueArray expected_array;
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr));
expected_array->length = input.num_rows();

expected_array->children[0]->length = input.num_rows();
ArrowBufferSetAllocator(ArrowArrayBuffer(expected_array->children[0], 0), noop_alloc);
NANOARROW_THROW_NOT_OK(
ArrowBufferSetAllocator(ArrowArrayBuffer(expected_array->children[0], 0), noop_alloc));
ArrowArrayValidityBitmap(expected_array->children[0])->buffer.data =
const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(input.view().column(0).null_mask()));

auto data_ptr = reinterpret_cast<uint8_t*>(result_dev_data->data());
ArrowBufferSetAllocator(
NANOARROW_THROW_NOT_OK(ArrowBufferSetAllocator(
ArrowArrayBuffer(expected_array->children[0], 1),
ArrowBufferDeallocator(
[](ArrowBufferAllocator* alloc, uint8_t*, int64_t) {
auto buf =
reinterpret_cast<std::unique_ptr<rmm::device_uvector<int64_t>>*>(alloc->private_data);
delete buf;
},
new std::unique_ptr<rmm::device_uvector<int64_t>>(std::move(result_dev_data))));
new std::unique_ptr<rmm::device_uvector<int64_t>>(std::move(result_dev_data)))));
ArrowArrayBuffer(expected_array->children[0], 1)->data = data_ptr;
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr));

auto got_arrow_array = cudf::to_arrow_device(std::move(input));
ASSERT_EQ(rmm::get_current_cuda_device().value(), got_arrow_array->device_id);
Expand All @@ -708,13 +722,13 @@ TEST_F(ToArrowDeviceTest, FixedPoint128Table)

nanoarrow::UniqueSchema expected_schema;
ArrowSchemaInit(expected_schema.get());
ArrowSchemaSetTypeStruct(expected_schema.get(), 1);
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeStruct(expected_schema.get(), 1));
ArrowSchemaInit(expected_schema->children[0]);
ArrowSchemaSetTypeDecimal(expected_schema->children[0],
NANOARROW_TYPE_DECIMAL128,
cudf::detail::max_precision<__int128_t>(),
-scale);
ArrowSchemaSetName(expected_schema->children[0], "a");
NANOARROW_THROW_NOT_OK(ArrowSchemaSetTypeDecimal(expected_schema->children[0],
NANOARROW_TYPE_DECIMAL128,
cudf::detail::max_precision<__int128_t>(),
-scale));
NANOARROW_THROW_NOT_OK(ArrowSchemaSetName(expected_schema->children[0], "a"));
expected_schema->children[0]->flags = 0;

auto got_arrow_schema =
Expand All @@ -723,11 +737,13 @@ TEST_F(ToArrowDeviceTest, FixedPoint128Table)
ArrowSchemaRelease(got_arrow_schema.get());

nanoarrow::UniqueArray expected_array;
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayInitFromSchema(expected_array.get(), expected_schema.get(), nullptr));
expected_array->length = input.num_rows();

populate_from_col<__int128_t>(expected_array->children[0], input.view().column(0));
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr);
NANOARROW_THROW_NOT_OK(
ArrowArrayFinishBuilding(expected_array.get(), NANOARROW_VALIDATION_LEVEL_NONE, nullptr));

auto got_arrow_array = cudf::to_arrow_device(std::move(input));
EXPECT_EQ(rmm::get_current_cuda_device().value(), got_arrow_array->device_id);
Expand Down

0 comments on commit 9ae32fe

Please sign in to comment.