mirror of
https://github.com/facebook/rocksdb.git
synced 2024-11-27 20:43:57 +00:00
Add comment explaining why RandomAccessFileReader* is not passed in at construction time
This commit is contained in:
parent
f20d12adc8
commit
5924a20443
|
@ -300,6 +300,14 @@ class FilePrefetchBuffer {
|
|||
// offset : the file offset to start reading from.
|
||||
// n : the number of bytes to read.
|
||||
//
|
||||
// Note: Why do we pass in the RandomAccessFileReader* for every single call
|
||||
// to Prefetch/PrefetchAsync/TryReadFromCache? Why can't we just pass it in at
|
||||
// construction time?
|
||||
// Although the RandomAccessFileReader* is often available when creating
|
||||
// the FilePrefetchBuffer, this is not true for BlobDB (see
|
||||
// BlobSource::GetBlob). The file reader gets retrieved or created inside
|
||||
// BlobFileCache::GetBlobFileReader, after we have already allocated a new
|
||||
// FilePrefetchBuffer.
|
||||
Status Prefetch(const IOOptions& opts, RandomAccessFileReader* reader,
|
||||
uint64_t offset, size_t n);
|
||||
|
||||
|
@ -488,6 +496,10 @@ class FilePrefetchBuffer {
|
|||
// Whether we reuse the file system provided buffer
|
||||
// Until we also handle the async read case, only enable this optimization
|
||||
// for the synchronous case when num_buffers_ = 1.
|
||||
// Note: Although it would be more convenient if we could determine
|
||||
// whether we want to reuse the file system buffer at construction time,
|
||||
// this would not work in all cases, because not all clients (BlobDB in
|
||||
// particular) have a RandomAccessFileReader* available at construction time.
|
||||
bool UseFSBuffer(RandomAccessFileReader* reader) {
|
||||
return reader->file() != nullptr && !reader->use_direct_io() &&
|
||||
fs_ != nullptr &&
|
||||
|
|
Loading…
Reference in a new issue