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

Function ExportDeviceRecordBatch

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

Source from the content-addressed store, hash-verified

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