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

Function ExportDeviceRecordBatch

cpp/src/arrow/c/bridge.cc:790–826  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790Status ExportDeviceRecordBatch(const RecordBatch& batch,
791 std::shared_ptr<Device::SyncEvent> sync,
792 struct ArrowDeviceArray* out,
793 struct ArrowSchema* out_schema) {
794 void* sync_event{nullptr};
795 if (sync) {
796 sync_event = sync->get_raw();
797 }
798
799 // XXX perhaps bypass ToStructArray for speed?
800 ARROW_ASSIGN_OR_RAISE(auto array, batch.ToStructArray());
801
802 SchemaExportGuard guard(out_schema);
803 if (out_schema != nullptr) {
804 // Export the schema, not the struct type, so as not to lose top-level metadata
805 RETURN_NOT_OK(ExportSchema(*batch.schema(), out_schema));
806 }
807
808 ARROW_ASSIGN_OR_RAISE(auto device_info, ValidateDeviceInfo(*array->data()));
809 if (!device_info.first) {
810 out->device_type = ARROW_DEVICE_CPU;
811 } else {
812 out->device_type = static_cast<ArrowDeviceType>(*device_info.first);
813 }
814 out->device_id = device_info.second;
815
816 ArrayExporter exporter(/*device_interface*/ true);
817 RETURN_NOT_OK(exporter.Export(array->data()));
818 exporter.Finish(&out->array);
819
820 auto* pdata = reinterpret_cast<ExportedArrayPrivateData*>(out->array.private_data);
821 pdata->sync_ = std::move(sync);
822 out->sync_event = sync_event;
823
824 guard.Detach();
825 return Status::OK();
826}
827
828//////////////////////////////////////////////////////////////////////////
829// C schema import

Callers 4

TEST_FFunction · 0.85
TestWithBatchFactoryMethod · 0.85
ExportStreamNextFunction · 0.85
extract_dataMethod · 0.85

Calls 8

ExportSchemaFunction · 0.70
OKFunction · 0.50
get_rawMethod · 0.45
schemaMethod · 0.45
ExportMethod · 0.45
dataMethod · 0.45
FinishMethod · 0.45
DetachMethod · 0.45

Tested by 2

TEST_FFunction · 0.68
TestWithBatchFactoryMethod · 0.68