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

Method DoRead

be/src/runtime/io/scan-range.cc:295–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295ReadOutcome ScanRange::DoRead(DiskQueue* queue, int disk_id) {
296 bool use_local_buffer = false;
297 bool use_mem_buffer = false;
298 if (disk_file_ != nullptr && disk_file_->disk_type() != DiskFileType::LOCAL
299 && disk_buffer_file_ != nullptr) {
300 // The sequence for acquiring the locks should always be from the local to
301 // the remote to avoid deadlocks.
302 shared_lock<shared_mutex> local_file_lock(*(disk_buffer_file_->GetFileLock()));
303 shared_lock<shared_mutex> remote_file_lock(*(disk_file_->GetFileLock()));
304 {
305 unique_lock<SpinLock> buffer_file_lock(*(disk_buffer_file_->GetStatusLock()));
306 unique_lock<SpinLock> file_lock(*(disk_file_->GetStatusLock()));
307 if (disk_buffer_file_->is_deleted(buffer_file_lock)
308 && disk_file_->is_deleted(file_lock)) {
309 // If both of the local buffer file and the remote file have been deleted,
310 // the only case could be the query is cancelled, so that both files are deleted.
311 return ReadOutcome::CANCELLED;
312 }
313
314 // The range can be read from local for two cases.
315 // 1. If the local buffer file is not deleted(evicted) yet.
316 // 2. A block of the file, which contains the range, has been read and stored in
317 // the memory.
318 // If we don't meet any of the cases, the range needs to be read from the remote.
319 if (!disk_buffer_file_->is_deleted(buffer_file_lock)) {
320 use_local_buffer = true;
321 } else if (disk_buffer_file_->CanReadFromReadBuffer(local_file_lock, offset_)) {
322 use_mem_buffer = true;
323 } else {
324 // Read from the remote file. The remote file must be in persisted status.
325 DCHECK(disk_file_->is_persisted(file_lock));
326 }
327 }
328 return DoReadInternal(
329 queue, disk_id, use_local_buffer, use_mem_buffer, &local_file_lock);
330 }
331 return DoReadInternal(queue, disk_id, use_local_buffer, use_mem_buffer);
332}
333
334Status ScanRange::ReadSubRanges(
335 DiskQueue* queue, BufferDescriptor* buffer_desc, bool* eof, FileReader* file_reader) {

Callers 1

DiskThreadLoopMethod · 0.80

Calls 6

GetFileLockMethod · 0.80
GetStatusLockMethod · 0.80
CanReadFromReadBufferMethod · 0.80
is_persistedMethod · 0.80
disk_typeMethod · 0.45
is_deletedMethod · 0.45

Tested by

no test coverage detected