| 280 | } // namespace |
| 281 | |
| 282 | Result<std::shared_ptr<StructArray>> RecordBatch::ToStructArray() const { |
| 283 | if (num_columns() != 0) { |
| 284 | // Only check the first column because `StructArray::Make` already checks that the |
| 285 | // child lengths are equal. |
| 286 | RETURN_NOT_OK(ValidateColumnLength(*this, 0)); |
| 287 | return StructArray::Make(columns(), schema()->fields()); |
| 288 | } |
| 289 | return std::make_shared<StructArray>(arrow::struct_({}), num_rows_, |
| 290 | std::vector<std::shared_ptr<Array>>{}, |
| 291 | /*null_bitmap=*/nullptr, |
| 292 | /*null_count=*/0, |
| 293 | /*offset=*/0); |
| 294 | } |
| 295 | |
| 296 | Result<std::shared_ptr<Tensor>> RecordBatch::ToTensor(bool null_to_nan, bool row_major, |
| 297 | MemoryPool* pool) const { |