提交 f6339de0 编写于 作者: H Hui Xiao 提交者: Facebook GitHub Bot

Clarify some SequentialFileReader::Read logic (#10002)

Summary:
**Context/Summary:**
The logic related to PositionedRead in SequentialFileReader::Read confused me a bit as discussed here https://github.com/facebook/rocksdb/pull/9973#discussion_r872869256. Therefore I added a drawing with help from cbi42.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/10002

Test Plan: - no code change

Reviewed By: anand1976, cbi42

Differential Revision: D36422632

Pulled By: hx235

fbshipit-source-id: 9a8311d2365564f90d216c430f542fc11b2d9cde
上级 b11ff347
......@@ -38,6 +38,13 @@ IOStatus SequentialFileReader::Read(size_t n, Slice* result, char* scratch) {
IOStatus io_s;
if (use_direct_io()) {
#ifndef ROCKSDB_LITE
//
// |-offset_advance-|---bytes returned--|
// |----------------------buf size-------------------------|
// | | | |
// aligned offset offset + n Roundup(offset + n,
// offset alignment)
//
size_t offset = offset_.fetch_add(n);
size_t alignment = file_->GetRequiredBufferAlignment();
size_t aligned_offset = TruncateToPageBoundary(alignment, offset);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册