MCPcopy Create free account
hub / github.com/apache/arrow / TestMoveWithArrayFactory

Method TestMoveWithArrayFactory

cpp/src/arrow/c/bridge_test.cc:728–754  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 10

ToResultFunction · 0.85
factoryFunction · 0.85
ArrowArrayMoveFunction · 0.85
ArrowArrayIsReleasedFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
ExportArrayFunction · 0.70
bytes_allocatedMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected