| 732 | |
| 733 | template <typename ArrayFactory, typename ExportCheckFunc> |
| 734 | void TestMoveWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) { |
| 735 | auto orig_bytes = pool_->bytes_allocated(); |
| 736 | |
| 737 | std::shared_ptr<Array> arr; |
| 738 | ASSERT_OK_AND_ASSIGN(arr, ToResult(factory())); |
| 739 | const ArrayData& data = *arr->data(); // non-owning reference |
| 740 | struct ArrowArray c_export_temp, c_export_final; |
| 741 | ASSERT_OK(ExportArray(*arr, &c_export_temp)); |
| 742 | |
| 743 | // Move the ArrowArray to its final location |
| 744 | ArrowArrayMove(&c_export_temp, &c_export_final); |
| 745 | ASSERT_TRUE(ArrowArrayIsReleased(&c_export_temp)); |
| 746 | |
| 747 | ArrayExportGuard guard(&c_export_final); |
| 748 | auto new_bytes = pool_->bytes_allocated(); |
| 749 | ASSERT_GT(new_bytes, orig_bytes); |
| 750 | check_func(&c_export_final, data); |
| 751 | |
| 752 | // Release the shared_ptr<Array>, underlying data should be held alive |
| 753 | arr.reset(); |
| 754 | ASSERT_EQ(pool_->bytes_allocated(), new_bytes); |
| 755 | check_func(&c_export_final, data); |
| 756 | |
| 757 | // Release the ArrowArray, underlying data should be destroyed |
| 758 | guard.Release(); |
| 759 | ASSERT_EQ(pool_->bytes_allocated(), orig_bytes); |
| 760 | } |
| 761 | |
| 762 | template <typename ArrayFactory> |
| 763 | void TestMoveNested(ArrayFactory&& factory) { |
nothing calls this directly
no test coverage detected