Skip to content

Commit

Permalink
Add precondition assertions for file prefetch buffer reads
Browse files Browse the repository at this point in the history
  • Loading branch information
archang19 committed Dec 6, 2024
1 parent 31408c0 commit 0ace993
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions file/file_prefetch_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,9 @@ bool FilePrefetchBuffer::TryReadFromCacheUntracked(
if (copy_to_overlap_buffer) {
buf = overlap_buf_;
}
assert(buf->offset_ <= offset);
uint64_t offset_in_buffer = offset - buf->offset_;
assert(n <= buf->CurrentSize() - offset_in_buffer);
*result = Slice(buf->buffer_.BufferStart() + offset_in_buffer, n);
if (prefetched) {
readahead_size_ = std::min(max_readahead_size_, readahead_size_ * 2);
Expand Down

0 comments on commit 0ace993

Please sign in to comment.