| 614 | } |
| 615 | |
| 616 | Result<std::shared_ptr<Table>> RunEndEncodeTableColumns( |
| 617 | const Table& table, const std::vector<int>& column_indices) { |
| 618 | const int num_columns = table.num_columns(); |
| 619 | std::vector<std::shared_ptr<ChunkedArray>> encoded_columns; |
| 620 | encoded_columns.reserve(num_columns); |
| 621 | std::vector<std::shared_ptr<Field>> encoded_fields; |
| 622 | encoded_fields.reserve(num_columns); |
| 623 | for (int i = 0; i < num_columns; i++) { |
| 624 | const auto& field = table.schema()->field(i); |
| 625 | if (std::find(column_indices.begin(), column_indices.end(), i) != |
| 626 | column_indices.end()) { |
| 627 | ARROW_ASSIGN_OR_RAISE(auto run_end_encoded, |
| 628 | arrow::compute::RunEndEncode(table.column(i))); |
| 629 | ARROW_DCHECK_EQ(run_end_encoded.kind(), Datum::CHUNKED_ARRAY); |
| 630 | encoded_columns.push_back(run_end_encoded.chunked_array()); |
| 631 | auto encoded_type = arrow::run_end_encoded(arrow::int32(), field->type()); |
| 632 | encoded_fields.push_back(field->WithType(encoded_type)); |
| 633 | } else { |
| 634 | encoded_columns.push_back(table.column(i)); |
| 635 | encoded_fields.push_back(field); |
| 636 | } |
| 637 | } |
| 638 | auto updated_schema = arrow::schema(std::move(encoded_fields)); |
| 639 | return Table::Make(std::move(updated_schema), std::move(encoded_columns)); |
| 640 | } |
| 641 | |
| 642 | } // namespace acero |
| 643 | } // namespace arrow |
no test coverage detected