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

Method CanReadFromReadBuffer

be/src/runtime/io/disk-file.h:392–399  ·  view source on GitHub ↗

Check if there is an available local memory buffer for the specific offset. Caller should hold the physical lock of the disk file in case the object is destroyed. But the caller should not hold the lock of the memory block because the IsStatus() would require the lock.

Source from the content-addressed store, hash-verified

390 // destroyed. But the caller should not hold the lock of the memory block because the
391 // IsStatus() would require the lock.
392 bool CanReadFromReadBuffer(
393 const boost::shared_lock<boost::shared_mutex>& lock, int64_t offset) {
394 if (!IsBatchReadEnabled()) return false;
395 DCHECK(lock.mutex() == &physical_file_lock_ && lock.owns_lock());
396 MemBlock* read_buffer_block = GetBufferBlock(GetReadBufferIndex(offset));
397 return read_buffer_block != nullptr
398 && read_buffer_block->IsStatus(MemBlockStatus::WRITTEN);
399 }
400
401 // Return if batch reading is enabled.
402 bool IsBatchReadEnabled() { return read_buffer_ != nullptr; }

Callers 1

DoReadMethod · 0.80

Calls 3

owns_lockMethod · 0.80
IsStatusMethod · 0.80
mutexMethod · 0.45

Tested by

no test coverage detected