| 467 | } |
| 468 | |
| 469 | static std::shared_ptr<ChunkedArray> ToChunked(const std::shared_ptr<Array>& array, |
| 470 | double chunk_proportion = 1.0) { |
| 471 | auto struct_array = internal::checked_pointer_cast<StructArray>(array); |
| 472 | const auto num_rows = struct_array->length(); |
| 473 | const auto chunk_length = static_cast<int64_t>(std::ceil(num_rows * chunk_proportion)); |
| 474 | |
| 475 | ArrayVector chunks; |
| 476 | for (int64_t offset = 0; offset < num_rows;) { |
| 477 | int64_t slice_length = std::min(chunk_length, num_rows - offset); |
| 478 | chunks.push_back(*struct_array->SliceSafe(offset, slice_length)); |
| 479 | offset += slice_length; |
| 480 | } |
| 481 | |
| 482 | return *ChunkedArray::Make(std::move(chunks)); |
| 483 | } |
| 484 | |
| 485 | static std::shared_ptr<Table> ToTable(const std::shared_ptr<Array>& array, |
| 486 | double chunk_proportion = 1.0) { |