MCPcopy Create free account
hub / github.com/apache/impala / AddRangeToDisk

Method AddRangeToDisk

be/src/runtime/io/request-context.cc:372–418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void RequestContext::AddRangeToDisk(const unique_lock<mutex>& lock,
373 RequestRange* range, ScheduleMode schedule_mode) {
374 DCHECK(lock.mutex() == &lock_ && lock.owns_lock());
375 DCHECK_EQ(state_, Active) << DebugString();
376 PerDiskState* disk_state = &disk_states_[range->disk_id()];
377 if (disk_state->done()) {
378 DCHECK_EQ(disk_state->num_remaining_ranges(), 0);
379 disk_state->set_done(false);
380 ++num_disks_with_ranges_;
381 }
382 if (range->request_type() == RequestType::READ) {
383 ScanRange* scan_range = static_cast<ScanRange*>(range);
384 if (schedule_mode == ScheduleMode::IMMEDIATELY) {
385 ScheduleScanRange(lock, scan_range);
386 } else if (schedule_mode != ScheduleMode::BY_CALLER) {
387 if (schedule_mode == ScheduleMode::UPON_GETNEXT_TAIL) {
388 disk_state->unstarted_scan_ranges()->Enqueue(scan_range);
389 } else {
390 DCHECK_ENUM_EQ(schedule_mode, ScheduleMode::UPON_GETNEXT_HEAD);
391 disk_state->unstarted_scan_ranges()->PushFront(scan_range);
392 }
393 num_unstarted_scan_ranges_.Add(1);
394 // If there's no 'next_scan_range_to_start', schedule this RequestContext so that
395 // one of the 'unstarted_scan_ranges' will become the 'next_scan_range_to_start'.
396 if (disk_state->next_scan_range_to_start() == nullptr) {
397 disk_state->ScheduleContext(lock, this, range->disk_id());
398 }
399 }
400 } else if (range->request_type() == RequestType::WRITE) {
401 DCHECK(schedule_mode == ScheduleMode::IMMEDIATELY) << static_cast<int>(schedule_mode);
402 WriteRange* write_range = static_cast<WriteRange*>(range);
403 disk_state->unstarted_write_ranges()->Enqueue(write_range);
404
405 // Ensure that the context is scheduled so that the write range gets picked up.
406 // ScheduleContext() has no effect if already scheduled, so this is safe to do always.
407 disk_state->ScheduleContext(lock, this, range->disk_id());
408 } else {
409 DCHECK(range->request_type() == RequestType::FILE_UPLOAD
410 || range->request_type() == RequestType::FILE_FETCH);
411 DCHECK(schedule_mode == ScheduleMode::IMMEDIATELY) << static_cast<int>(schedule_mode);
412 RemoteOperRange* oper_range = static_cast<RemoteOperRange*>(range);
413 disk_state->unstarted_remote_file_oper_ranges()->Enqueue(oper_range);
414 disk_state->ScheduleContext(lock, this, range->disk_id());
415 }
416
417 ++disk_state->num_remaining_ranges();
418}
419
420Status RequestContext::AddScanRanges(
421 const vector<ScanRange*>& ranges, EnqueueLocation enqueue_location) {

Callers

nothing calls this directly

Calls 15

owns_lockMethod · 0.80
num_remaining_rangesMethod · 0.80
set_doneMethod · 0.80
request_typeMethod · 0.80
unstarted_scan_rangesMethod · 0.80
PushFrontMethod · 0.80
ScheduleContextMethod · 0.80
DebugStringFunction · 0.50
mutexMethod · 0.45

Tested by

no test coverage detected