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

Method TestMoveChildWithArrayFactory

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

Source from the content-addressed store, hash-verified

776
777 template <typename ArrayFactory, typename ExportCheckFunc>
778 void TestMoveChildWithArrayFactory(ArrayFactory&& factory, int64_t child_id,
779 ExportCheckFunc&& check_func) {
780 auto orig_bytes = pool_->bytes_allocated();
781
782 std::shared_ptr<Array> arr;
783 ASSERT_OK_AND_ASSIGN(arr, ToResult(factory()));
784 struct ArrowArray c_export_parent, c_export_child;
785 ASSERT_OK(ExportArray(*arr, &c_export_parent));
786
787 auto bytes_with_parent = pool_->bytes_allocated();
788 ASSERT_GT(bytes_with_parent, orig_bytes);
789
790 // Move the child ArrowArray to its final location
791 {
792 ArrayExportGuard parent_guard(&c_export_parent);
793 ASSERT_LT(child_id, c_export_parent.n_children);
794 ArrowArrayMove(c_export_parent.children[child_id], &c_export_child);
795 }
796 ArrayExportGuard child_guard(&c_export_child);
797
798 // Now parent is released
799 ASSERT_TRUE(ArrowArrayIsReleased(&c_export_parent));
800 auto bytes_with_child = pool_->bytes_allocated();
801 ASSERT_LT(bytes_with_child, bytes_with_parent);
802 ASSERT_GT(bytes_with_child, orig_bytes);
803
804 const ArrayData& data = *arr->data()->child_data[child_id]; // non-owning reference
805 check_func(&c_export_child, data);
806
807 // Release the shared_ptr<Array>, some underlying data should be held alive
808 arr.reset();
809 ASSERT_LT(pool_->bytes_allocated(), bytes_with_child);
810 ASSERT_GT(pool_->bytes_allocated(), orig_bytes);
811 check_func(&c_export_child, data);
812
813 // Release the ArrowArray, underlying data should be destroyed
814 child_guard.Release();
815 ASSERT_EQ(pool_->bytes_allocated(), orig_bytes);
816 }
817
818 template <typename ArrayFactory>
819 void TestMoveChild(ArrayFactory&& factory, int64_t child_id) {

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