MCPcopy Create free account
hub / github.com/apache/arrow / EvolveBatch

Method EvolveBatch

cpp/src/arrow/dataset/dataset.cc:418–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

MakeNullScalarFunction · 0.85
columnsMethod · 0.80
push_backMethod · 0.80
ExecBatchFunction · 0.50
num_columnsMethod · 0.45
sizeMethod · 0.45
reserveMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
num_rowsMethod · 0.45

Tested by

no test coverage detected