| 323 | } |
| 324 | |
| 325 | Result<std::shared_ptr<Table>> Table::FromChunkedStructArray( |
| 326 | const std::shared_ptr<ChunkedArray>& array) { |
| 327 | auto type = array->type(); |
| 328 | if (type->id() != Type::STRUCT) { |
| 329 | return Status::Invalid("Expected a chunked struct array, got ", *type); |
| 330 | } |
| 331 | int num_columns = type->num_fields(); |
| 332 | int num_chunks = array->num_chunks(); |
| 333 | |
| 334 | const auto& struct_chunks = array->chunks(); |
| 335 | std::vector<std::shared_ptr<ChunkedArray>> columns(num_columns); |
| 336 | for (int i = 0; i < num_columns; ++i) { |
| 337 | ArrayVector chunks(num_chunks); |
| 338 | std::transform(struct_chunks.begin(), struct_chunks.end(), chunks.begin(), |
| 339 | [i](const std::shared_ptr<Array>& struct_chunk) { |
| 340 | return static_cast<const StructArray&>(*struct_chunk).field(i); |
| 341 | }); |
| 342 | columns[i] = |
| 343 | std::make_shared<ChunkedArray>(std::move(chunks), type->field(i)->type()); |
| 344 | } |
| 345 | |
| 346 | return Table::Make(::arrow::schema(type->fields()), std::move(columns), |
| 347 | array->length()); |
| 348 | } |
| 349 | |
| 350 | Result<std::shared_ptr<Tensor>> Table::ToTensor(bool null_to_nan, bool row_major, |
| 351 | MemoryPool* pool) const { |
nothing calls this directly
no test coverage detected