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

Function ExportDeviceRecordBatch

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

Source from the content-addressed store, hash-verified

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