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

Method TestMoveChildWithArrayFactory

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

Source from the content-addressed store, hash-verified

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