| 1446 | |
| 1447 | template <typename ArrayFactory, typename ExportCheckFunc> |
| 1448 | void TestWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) { |
| 1449 | auto orig_bytes = pool_->bytes_allocated(); |
| 1450 | |
| 1451 | std::shared_ptr<Array> arr; |
| 1452 | ASSERT_OK_AND_ASSIGN(arr, ToResult(factory())); |
| 1453 | ARROW_SCOPED_TRACE("type = ", arr->type()->ToString(), |
| 1454 | ", array data = ", arr->ToString()); |
| 1455 | const ArrayData& data = *arr->data(); // non-owning reference |
| 1456 | struct ArrowDeviceArray c_export; |
| 1457 | std::shared_ptr<Device::SyncEvent> sync{nullptr}; |
| 1458 | ASSERT_OK(ExportDeviceArray(*arr, sync, &c_export)); |
| 1459 | |
| 1460 | ArrayExportGuard guard(&c_export.array); |
| 1461 | auto new_bytes = pool_->bytes_allocated(); |
| 1462 | ASSERT_GT(new_bytes, orig_bytes); |
| 1463 | |
| 1464 | // Release the shared_ptr<Array>, underlying data should be held alive |
| 1465 | arr.reset(); |
| 1466 | ASSERT_EQ(pool_->bytes_allocated(), new_bytes); |
| 1467 | check_func(&c_export, data, kMyDeviceType, 1, nullptr); |
| 1468 | |
| 1469 | // Release the ArrowArray, underlying data should be destroyed |
| 1470 | guard.Release(); |
| 1471 | ASSERT_EQ(pool_->bytes_allocated(), orig_bytes); |
| 1472 | } |
| 1473 | |
| 1474 | template <typename ArrayFactory> |
| 1475 | void TestNested(ArrayFactory&& factory) { |
nothing calls this directly
no test coverage detected