| 764 | } // namespace |
| 765 | |
| 766 | Status ExportDeviceArray(const Array& array, std::shared_ptr<Device::SyncEvent> sync, |
| 767 | struct ArrowDeviceArray* out, struct ArrowSchema* out_schema) { |
| 768 | void* sync_event = sync ? sync->get_raw() : nullptr; |
| 769 | |
| 770 | SchemaExportGuard guard(out_schema); |
| 771 | if (out_schema != nullptr) { |
| 772 | RETURN_NOT_OK(ExportType(*array.type(), out_schema)); |
| 773 | } |
| 774 | |
| 775 | ARROW_ASSIGN_OR_RAISE(auto device_info, ValidateDeviceInfo(*array.data())); |
| 776 | if (!device_info.first) { |
| 777 | out->device_type = ARROW_DEVICE_CPU; |
| 778 | } else { |
| 779 | out->device_type = static_cast<ArrowDeviceType>(*device_info.first); |
| 780 | } |
| 781 | out->device_id = device_info.second; |
| 782 | |
| 783 | ArrayExporter exporter(/*device_interface*/ true); |
| 784 | RETURN_NOT_OK(exporter.Export(array.data())); |
| 785 | exporter.Finish(&out->array); |
| 786 | |
| 787 | auto* pdata = reinterpret_cast<ExportedArrayPrivateData*>(out->array.private_data); |
| 788 | pdata->sync_ = std::move(sync); |
| 789 | out->sync_event = sync_event; |
| 790 | |
| 791 | guard.Detach(); |
| 792 | return Status::OK(); |
| 793 | } |
| 794 | |
| 795 | Status ExportDeviceRecordBatch(const RecordBatch& batch, |
| 796 | std::shared_ptr<Device::SyncEvent> sync, |