| 416 | }; |
| 417 | |
| 418 | Result<compute::ExecBatch> EvolveBatch( |
| 419 | const std::shared_ptr<RecordBatch>& batch, |
| 420 | const std::vector<FieldPath>& dataset_selection, |
| 421 | const FragmentSelection& selection) const override { |
| 422 | // In this simple evolution strategy every column is either missing from the fragment |
| 423 | // or included in our load of the fragment. For the columns that are missing we |
| 424 | // populate a null array and the columns that we loaded we populate in the correct |
| 425 | // spot. |
| 426 | DCHECK_EQ(batch->num_columns(), static_cast<int>(selection.columns().size())); |
| 427 | const BasicFragmentSelection& selection_cast = |
| 428 | dynamic_cast<const BasicFragmentSelection&>(selection); |
| 429 | std::size_t num_out_columns = |
| 430 | selection_cast.columns().size() + selection_cast.missing_columns().size(); |
| 431 | std::vector<Datum> columns; |
| 432 | columns.reserve(num_out_columns); |
| 433 | auto missing_itr = selection_cast.missing_columns().begin(); |
| 434 | auto batch_itr = batch->columns().begin(); |
| 435 | for (std::size_t idx = 0; idx < num_out_columns; idx++) { |
| 436 | if (missing_itr != selection_cast.missing_columns().end() && |
| 437 | missing_itr->idx == idx) { |
| 438 | columns.push_back(MakeNullScalar(missing_itr->type)); |
| 439 | missing_itr++; |
| 440 | } else { |
| 441 | columns.push_back(*batch_itr); |
| 442 | batch_itr++; |
| 443 | } |
| 444 | } |
| 445 | return compute::ExecBatch(columns, batch->num_rows()); |
| 446 | } |
| 447 | |
| 448 | std::string ToString() const override { return "basic-fragment-evolution"; } |
| 449 |
nothing calls this directly
no test coverage detected