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