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

Method PickTasks

cpp/src/arrow/acero/task_util.cc:163–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163std::vector<std::pair<int, int64_t>> TaskSchedulerImpl::PickTasks(int num_tasks,
164 int start_task_group) {
165 std::vector<std::pair<int, int64_t>> result;
166 for (size_t i = 0; i < task_groups_.size(); ++i) {
167 int task_group_id = static_cast<int>((start_task_group + i) % (task_groups_.size()));
168 TaskGroup& task_group = task_groups_[task_group_id];
169
170 {
171 std::lock_guard<std::mutex> lock(mutex_);
172 if (task_group.state_ != TaskGroupState::READY) {
173 continue;
174 }
175 }
176
177 int num_tasks_remaining = num_tasks - static_cast<int>(result.size());
178 int64_t start_task =
179 task_group.num_tasks_started_.value.fetch_add(num_tasks_remaining);
180 if (start_task >= task_group.num_tasks_present_) {
181 continue;
182 }
183
184 int num_tasks_current_group = num_tasks_remaining;
185 if (start_task + num_tasks_current_group >= task_group.num_tasks_present_) {
186 {
187 std::lock_guard<std::mutex> lock(mutex_);
188 if (task_group.state_ == TaskGroupState::READY) {
189 task_group.state_ = TaskGroupState::ALL_TASKS_STARTED;
190 }
191 }
192 num_tasks_current_group =
193 static_cast<int>(task_group.num_tasks_present_ - start_task);
194 }
195
196 for (int64_t task_id = start_task; task_id < start_task + num_tasks_current_group;
197 ++task_id) {
198 result.push_back(std::make_pair(task_group_id, task_id));
199 }
200
201 if (static_cast<int>(result.size()) == num_tasks) {
202 break;
203 }
204 }
205
206 return result;
207}
208
209Status TaskSchedulerImpl::ExecuteTask(size_t thread_id, int group_id, int64_t task_id,
210 bool* task_group_finished) {

Callers

nothing calls this directly

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected