Return the actual size of the specific read buffer block.
| 351 | |
| 352 | // Return the actual size of the specific read buffer block. |
| 353 | int64_t GetReadBuffActualSize(int buffer_idx) { |
| 354 | DCheckReadBufferIdx(buffer_idx); |
| 355 | std::lock_guard<SpinLock> lock(read_buffer_->read_buffer_ctrl_lock_); |
| 356 | int64_t cur_offset = read_buffer_->read_buffer_block_offsets_[buffer_idx]; |
| 357 | DCHECK(cur_offset != DISK_FILE_INVALID_FILE_OFFSET); |
| 358 | while (buffer_idx != num_of_read_buffers() - 1) { |
| 359 | DCHECK_LT(buffer_idx, num_of_read_buffers() - 1); |
| 360 | int64_t nxt_offset = read_buffer_->read_buffer_block_offsets_[buffer_idx + 1]; |
| 361 | if (nxt_offset != DISK_FILE_INVALID_FILE_OFFSET) return nxt_offset - cur_offset; |
| 362 | buffer_idx++; |
| 363 | } |
| 364 | int64_t actual_file_size = actual_file_size_.Load(); |
| 365 | DCHECK_GT(actual_file_size, 0); |
| 366 | return actual_file_size - cur_offset; |
| 367 | } |
| 368 | |
| 369 | // Return the number of the page count in the read buffer block. |
| 370 | int64_t GetReadBuffPageCount(int buffer_idx) { |