| 709 | } |
| 710 | |
| 711 | Future<std::shared_ptr<Table>> AsyncScanner::ToTableAsync(Executor* cpu_executor) { |
| 712 | auto scan_options = scan_options_; |
| 713 | ARROW_ASSIGN_OR_RAISE( |
| 714 | auto positioned_batch_gen, |
| 715 | ScanBatchesUnorderedAsync(cpu_executor, /*sequence_fragments=*/false, |
| 716 | /*use_legacy_batching=*/true)); |
| 717 | /// Wraps the state in a shared_ptr to ensure that failing ScanTasks don't |
| 718 | /// invalidate concurrently running tasks when Finish() early returns |
| 719 | /// and the mutex/batches fail out of scope. |
| 720 | auto state = std::make_shared<AsyncTableAssemblyState>(); |
| 721 | |
| 722 | auto table_building_task = [state](const EnumeratedRecordBatch& batch) { |
| 723 | state->Emplace(batch); |
| 724 | return batch; |
| 725 | }; |
| 726 | |
| 727 | auto table_building_gen = |
| 728 | MakeMappedGenerator(positioned_batch_gen, table_building_task); |
| 729 | |
| 730 | return DiscardAllFromAsyncGenerator(table_building_gen).Then([state, scan_options]() { |
| 731 | return Table::FromRecordBatches(scan_options->projected_schema, state->Finish()); |
| 732 | }); |
| 733 | } |
| 734 | |
| 735 | Future<int64_t> AsyncScanner::CountRowsAsync(Executor* executor) { |
| 736 | ARROW_ASSIGN_OR_RAISE(auto fragment_gen, GetFragments()); |
nothing calls this directly
no test coverage detected