35505 {
35506 vector<shared_ptr<Task>> tasks;
35507
35508 BatchesToTaskTransformer transformer(batches);
35509 vector<BatchesForTask> task_data;
35511
35513 idx_t tuples_for_task = 0;
35514 idx_t start_index = transformer.GetIndex();
35515 idx_t end_index = start_index;
35516 while (tuples_for_task < DEFAULT_ROW_GROUP_SIZE) {
35517 idx_t batch_size;
35518 if (!transformer.TryGetNextBatchSize(batch_size)) {
35520 break;
35521 }
35522 end_index++;
35523 tuples_for_task += batch_size;
35524 }
35525 if (start_index == end_index) {
35526 break;
35527 }
35528 BatchesForTask batches_for_task;
35529 batches_for_task.tuple_count = tuples_for_task;
35530 batches_for_task.batches = batches.
BatchRange(start_index, end_index);
35531 task_data.push_back(batches_for_task);
35532 }
35533
35534
35535
35536
35537 idx_t record_batch_index = 0;
35538 for (auto &data : task_data) {
35539 const auto tuples = data.tuple_count;
35540
35543 auto total_batches = full_batches + !!remainder;
35544
35545 vector<idx_t> record_batch_indices(total_batches);
35546 for (idx_t i = 0; i < total_batches; i++) {
35547 record_batch_indices[i] = record_batch_index++;
35548 }
35549
35550 BatchCollectionChunkScanState scan_state(batches, data.batches,
pipeline->executor.context);
35551 tasks.push_back(make_uniq<ArrowBatchTask>(result, std::move(record_batch_indices),
pipeline->executor,
35552 shared_from_this(), std::move(scan_state), result.
names,
35554 }
35555
35556
35557 {
35558 vector<unique_ptr<ArrowArrayWrapper>> arrays;
35559 arrays.resize(record_batch_index);
35560 for (idx_t i = 0; i < record_batch_index; i++) {
35561 arrays[i] = make_uniq<ArrowArrayWrapper>();
35562 }
35563 result.SetArrowData(std::move(arrays));
35564 }
35565 D_ASSERT(!tasks.empty());
35566 SetTasks(std::move(tasks));
35567}
shared_ptr< Pipeline > pipeline
The pipeline that this event belongs to.
Definition duckdb.cpp:35137
vector< string > names
The names of the result.
Definition duckdb.hpp:19524
BatchedChunkIteratorRange BatchRange(idx_t begin=0, idx_t end=DConstants::INVALID_INDEX)
Create an iterator range from the provided indices.
atomic< bool > finished
Whether or not the event is finished executing.
Definition duckdb.cpp:35117