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