| 1468 | |
| 1469 | template <typename ArrayFactory, typename ExportCheckFunc> |
| 1470 | void TestWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) { |
| 1471 | auto orig_bytes = pool_->bytes_allocated(); |
| 1472 | |
| 1473 | std::shared_ptr<Array> arr; |
| 1474 | ASSERT_OK_AND_ASSIGN(arr, ToResult(factory())); |
| 1475 | ARROW_SCOPED_TRACE("type = ", arr->type()->ToString(), |
| 1476 | ", array data = ", arr->ToString()); |
| 1477 | const ArrayData& data = *arr->data(); // non-owning reference |
| 1478 | struct ArrowDeviceArray c_export; |
| 1479 | std::shared_ptr<Device::SyncEvent> sync{nullptr}; |
| 1480 | ASSERT_OK(ExportDeviceArray(*arr, sync, &c_export)); |
| 1481 | |
| 1482 | ArrayExportGuard guard(&c_export.array); |
| 1483 | auto new_bytes = pool_->bytes_allocated(); |
| 1484 | ASSERT_GT(new_bytes, orig_bytes); |
| 1485 | |
| 1486 | // Release the shared_ptr<Array>, underlying data should be held alive |
| 1487 | arr.reset(); |
| 1488 | ASSERT_EQ(pool_->bytes_allocated(), new_bytes); |
| 1489 | check_func(&c_export, data, kMyDeviceType, 1, nullptr); |
| 1490 | |
| 1491 | // Release the ArrowArray, underlying data should be destroyed |
| 1492 | guard.Release(); |
| 1493 | ASSERT_EQ(pool_->bytes_allocated(), orig_bytes); |
| 1494 | } |
| 1495 | |
| 1496 | template <typename ArrayFactory> |
| 1497 | void TestNested(ArrayFactory&& factory) { |
nothing calls this directly
no test coverage detected