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

Method TestWithArrayFactory

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

Source from the content-addressed store, hash-verified

1476
1477 template <typename ArrayFactory, typename ExportCheckFunc>
1478 void TestWithArrayFactory(ArrayFactory&& factory, ExportCheckFunc&& check_func) {
1479 auto orig_bytes = pool_->bytes_allocated();
1480
1481 std::shared_ptr<Array> arr;
1482 ASSERT_OK_AND_ASSIGN(arr, ToResult(factory()));
1483 ARROW_SCOPED_TRACE("type = ", arr->type()->ToString(),
1484 ", array data = ", arr->ToString());
1485 const ArrayData& data = *arr->data(); // non-owning reference
1486 struct ArrowDeviceArray c_export;
1487 std::shared_ptr<Device::SyncEvent> sync{nullptr};
1488 ASSERT_OK(ExportDeviceArray(*arr, sync, &c_export));
1489
1490 ArrayExportGuard guard(&c_export.array);
1491 auto new_bytes = pool_->bytes_allocated();
1492 ASSERT_GT(new_bytes, orig_bytes);
1493
1494 // Release the shared_ptr<Array>, underlying data should be held alive
1495 arr.reset();
1496 ASSERT_EQ(pool_->bytes_allocated(), new_bytes);
1497 check_func(&c_export, data, kMyDeviceType, 1, nullptr);
1498
1499 // Release the ArrowArray, underlying data should be destroyed
1500 guard.Release();
1501 ASSERT_EQ(pool_->bytes_allocated(), orig_bytes);
1502 }
1503
1504 template <typename ArrayFactory>
1505 void TestNested(ArrayFactory&& factory) {

Callers

nothing calls this directly

Calls 10

ToResultFunction · 0.85
factoryFunction · 0.85
ExportDeviceArrayFunction · 0.85
ASSERT_OK_AND_ASSIGNFunction · 0.70
bytes_allocatedMethod · 0.45
ToStringMethod · 0.45
typeMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected