| 695 | } |
| 696 | |
| 697 | Status ExportRecordBatch(const RecordBatch& batch, struct ArrowArray* out, |
| 698 | struct ArrowSchema* out_schema) { |
| 699 | // XXX perhaps bypass ToStructArray() for speed? |
| 700 | ARROW_ASSIGN_OR_RAISE(auto array, batch.ToStructArray()); |
| 701 | |
| 702 | SchemaExportGuard guard(out_schema); |
| 703 | if (out_schema != nullptr) { |
| 704 | // Export the schema, not the struct type, so as not to lose top-level metadata |
| 705 | RETURN_NOT_OK(ExportSchema(*batch.schema(), out_schema)); |
| 706 | } |
| 707 | ArrayExporter exporter; |
| 708 | RETURN_NOT_OK(exporter.Export(array->data())); |
| 709 | exporter.Finish(out); |
| 710 | guard.Detach(); |
| 711 | return Status::OK(); |
| 712 | } |
| 713 | |
| 714 | ////////////////////////////////////////////////////////////////////////// |
| 715 | // C device arrays |