| 453 | } |
| 454 | |
| 455 | static std::shared_ptr<ChunkedArray> ToChunked(const std::shared_ptr<Array>& array, |
| 456 | double chunk_proportion = 1.0) { |
| 457 | auto struct_array = internal::checked_pointer_cast<StructArray>(array); |
| 458 | const auto num_rows = struct_array->length(); |
| 459 | const auto chunk_length = static_cast<int64_t>(std::ceil(num_rows * chunk_proportion)); |
| 460 | |
| 461 | ArrayVector chunks; |
| 462 | for (int64_t offset = 0; offset < num_rows;) { |
| 463 | int64_t slice_length = std::min(chunk_length, num_rows - offset); |
| 464 | chunks.push_back(*struct_array->SliceSafe(offset, slice_length)); |
| 465 | offset += slice_length; |
| 466 | } |
| 467 | |
| 468 | return *ChunkedArray::Make(std::move(chunks)); |
| 469 | } |
| 470 | |
| 471 | static std::shared_ptr<Table> ToTable(const std::shared_ptr<Array>& array, |
| 472 | double chunk_proportion = 1.0) { |