Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::CachingFileHandle Struct Reference
Collaboration diagram for duckdb::CachingFileHandle:

Public Types

using CachedFileRangeOverlap = ExternalFileCache::CachedFileRangeOverlap
using CachedFileRange = ExternalFileCache::CachedFileRange
using CachedFile = ExternalFileCache::CachedFile

Public Member Functions

DUCKDB_API CachingFileHandle (QueryContext context, CachingFileSystem &caching_file_system, const OpenFileInfo &path, FileOpenFlags flags, optional_ptr< FileOpener > opener, CachedFile &cached_file)
DUCKDB_API FileHandle & GetFileHandle ()
 Get the underlying FileHandle.
DUCKDB_API BufferHandle Read (data_ptr_t &buffer, idx_t nr_bytes, idx_t location)
DUCKDB_API BufferHandle Read (data_ptr_t &buffer, idx_t &nr_bytes)
 Read (non-seeking) nr bytes from the file (or cache), same as above, also sets nr_bytes to actually read bytes.
DUCKDB_API string GetPath () const
 Get some properties of the file.
DUCKDB_API idx_t GetFileSize ()
DUCKDB_API timestamp_t GetLastModifiedTime ()
DUCKDB_API string GetVersionTag ()
DUCKDB_API bool Validate () const
DUCKDB_API bool CanSeek ()
DUCKDB_API bool IsRemoteFile () const
DUCKDB_API bool OnDiskFile ()
DUCKDB_API idx_t SeekPosition ()
DUCKDB_API void Seek (idx_t location)

Private Member Functions

const string & GetVersionTag (const unique_ptr< StorageLockKey > &guard)
 Get the version tag of the file (for checking cache invalidation).
BufferHandle TryReadFromCache (data_ptr_t &buffer, idx_t nr_bytes, idx_t location, vector< shared_ptr< CachedFileRange > > &overlapping_ranges, optional_idx &start_location_of_next_range)
BufferHandle TryReadFromFileRange (const unique_ptr< StorageLockKey > &guard, CachedFileRange &file_range, data_ptr_t &buffer, idx_t nr_bytes, idx_t location)
 Try to read from the specified range, return an invalid BufferHandle if it fails.
BufferHandle TryInsertFileRange (BufferHandle &pin, data_ptr_t &buffer, idx_t nr_bytes, idx_t location, shared_ptr< CachedFileRange > &new_file_range)
 Try to insert the file range into the cache.
idx_t ReadAndCopyInterleaved (const vector< shared_ptr< CachedFileRange > > &overlapping_ranges, const shared_ptr< CachedFileRange > &new_file_range, data_ptr_t buffer, idx_t nr_bytes, idx_t location, bool actually_read)

Private Attributes

QueryContext context
CachingFileSystem & caching_file_system
 The client caching file system that was used to create this CachingFileHandle.
ExternalFileCache & external_file_cache
 The DB external file cache.
OpenFileInfo path
 For opening the file (possibly with extra info).
FileOpenFlags flags
 Flags used to open the file.
optional_ptr< FileOpener > opener
 File opener, which contains file open context.
CacheValidationMode validate
 Cache validation mode for this file.
CachedFile & cached_file
 The associated CachedFile with cached ranges.
unique_ptr< FileHandle > file_handle
 The underlying FileHandle (optional).
timestamp_t last_modified
 Last modified time and version tag (if FileHandle is opened).
string version_tag
idx_t position
 Current position (if non-seeking reads).

Constructor & Destructor Documentation

◆ CachingFileHandle()

duckdb::CachingFileHandle::CachingFileHandle ( QueryContext context,
CachingFileSystem & caching_file_system,
const OpenFileInfo & path,
FileOpenFlags flags,
optional_ptr< FileOpener > opener,
CachedFile & cached_file )
388047 : context(context), caching_file_system(caching_file_system_p),
388048 external_file_cache(caching_file_system.external_file_cache), path(path_p), flags(flags_p), opener(opener_p),
388049 validate(
388050 ExternalFileCacheUtil::GetCacheValidationMode(path_p, context.GetClientContext(), caching_file_system_p.db)),
388051 cached_file(cached_file_p), position(0) {
388052 if (!external_file_cache.IsEnabled() || Validate()) {
388053 // If caching is disabled, or if we must validate cache entries, we always have to open the file
388054 GetFileHandle();
388055 return;
388056 }
388057 // If we don't have any cached file ranges, we must also open the file.
388058 auto guard = cached_file.lock.GetSharedLock();
388059 if (cached_file.Ranges(guard).empty()) {
388060 guard.reset();
388061 GetFileHandle();
388062 }
388063}
DUCKDB_API FileHandle & GetFileHandle()
Get the underlying FileHandle.
Definition duckdb.cpp:388068
CachedFile & cached_file
The associated CachedFile with cached ranges.
Definition duckdb.cpp:144761
CachingFileSystem & caching_file_system
The client caching file system that was used to create this CachingFileHandle.
Definition duckdb.cpp:144749
ExternalFileCache & external_file_cache
The DB external file cache.
Definition duckdb.cpp:144751
CacheValidationMode validate
Cache validation mode for this file.
Definition duckdb.cpp:144759
OpenFileInfo path
For opening the file (possibly with extra info).
Definition duckdb.cpp:144753
FileOpenFlags flags
Flags used to open the file.
Definition duckdb.cpp:144755
optional_ptr< FileOpener > opener
File opener, which contains file open context.
Definition duckdb.cpp:144757
idx_t position
Current position (if non-seeking reads).
Definition duckdb.cpp:144770
static CacheValidationMode GetCacheValidationMode(const OpenFileInfo &info, optional_ptr< ClientContext > client_context, DatabaseInstance &db)
Definition duckdb.cpp:413435

◆ ~CachingFileHandle()

duckdb::CachingFileHandle::~CachingFileHandle ( )
388065 {
388066}

Member Function Documentation

◆ GetFileHandle()

FileHandle & duckdb::CachingFileHandle::GetFileHandle ( )

Get the underlying FileHandle.

388068 {
388069 if (!file_handle) {
388070 file_handle = caching_file_system.file_system.OpenFile(path, flags, opener);
388071 last_modified = caching_file_system.file_system.GetLastModifiedTime(*file_handle);
388072 version_tag = caching_file_system.file_system.GetVersionTag(*file_handle);
388073
388074 auto guard = cached_file.lock.GetExclusiveLock();
388075 if (!cached_file.IsValid(guard, Validate(), version_tag, last_modified)) {
388076 cached_file.Ranges(guard).clear(); // Invalidate entire cache
388077 }
388078 cached_file.FileSize(guard) = file_handle->GetFileSize();
388079 cached_file.LastModified(guard) = last_modified;
388080 cached_file.VersionTag(guard) = version_tag;
388081 cached_file.CanSeek(guard) = file_handle->CanSeek();
388082 cached_file.OnDiskFile(guard) = file_handle->OnDiskFile();
388083 }
388084 return *file_handle;
388085}
timestamp_t last_modified
Last modified time and version tag (if FileHandle is opened).
Definition duckdb.cpp:144766
unique_ptr< FileHandle > file_handle
The underlying FileHandle (optional).
Definition duckdb.cpp:144764
Here is the caller graph for this function:

◆ Read() [1/2]

BufferHandle duckdb::CachingFileHandle::Read ( data_ptr_t & buffer,
idx_t nr_bytes,
idx_t location )

Read (seek) nr_bytes from the file (or cache) at location. The pointer will be set to the requested range The buffer is guaranteed to stay in memory as long as the returned BufferHandle is in scope

388087 {
388088 BufferHandle result;
388089 if (!external_file_cache.IsEnabled()) {
388090 result = external_file_cache.GetBufferManager().Allocate(MemoryTag::EXTERNAL_FILE_CACHE, nr_bytes);
388091 buffer = result.Ptr();
388092 GetFileHandle().Read(context, buffer, nr_bytes, location);
388093 return result;
388094 }
388095
388096 // Try to read from the cache, filling overlapping_ranges in the process
388097 vector<shared_ptr<CachedFileRange>> overlapping_ranges;
388098 optional_idx start_location_of_next_range;
388099 result = TryReadFromCache(buffer, nr_bytes, location, overlapping_ranges, start_location_of_next_range);
388100 if (result.IsValid()) {
388101 return result; // Success
388102 }
388103
388104 idx_t new_nr_bytes = nr_bytes;
388105 if (start_location_of_next_range.IsValid()) {
388106 const idx_t nr_bytes_to_be_added = start_location_of_next_range.GetIndex() - location - nr_bytes;
388107 if (ShouldExpandToFillGap(nr_bytes, nr_bytes_to_be_added)) {
388108 // Grow the range from location to start_location_of_next_range, so that to fill gaps in the cached ranges
388109 new_nr_bytes = nr_bytes + nr_bytes_to_be_added;
388110 }
388111 }
388112
388113 // Finally, if we weren't able to find the file range in the cache, we have to create a new file range
388114 result = external_file_cache.GetBufferManager().Allocate(MemoryTag::EXTERNAL_FILE_CACHE, new_nr_bytes);
388115 auto new_file_range =
388116 make_shared_ptr<CachedFileRange>(result.GetBlockHandle(), new_nr_bytes, location, version_tag);
388117 buffer = result.Ptr();
388118
388119 // Interleave reading and copying from cached buffers
388120 if (OnDiskFile()) {
388121 // On-disk file: prefer interleaving reading and copying from cached buffers
388122 ReadAndCopyInterleaved(overlapping_ranges, new_file_range, buffer, new_nr_bytes, location, true);
388123 } else {
388124 // Remote file: prefer interleaving reading and copying from cached buffers only if reduces number of real
388125 // reads
388126 if (ReadAndCopyInterleaved(overlapping_ranges, new_file_range, buffer, new_nr_bytes, location, false) <= 1) {
388127 ReadAndCopyInterleaved(overlapping_ranges, new_file_range, buffer, new_nr_bytes, location, true);
388128 } else {
388129 GetFileHandle().Read(context, buffer, new_nr_bytes, location);
388130 }
388131 }
388132
388133 return TryInsertFileRange(result, buffer, new_nr_bytes, location, new_file_range);
388134}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
BufferHandle TryReadFromCache(data_ptr_t &buffer, idx_t nr_bytes, idx_t location, vector< shared_ptr< CachedFileRange > > &overlapping_ranges, optional_idx &start_location_of_next_range)
Definition duckdb.cpp:388249
idx_t ReadAndCopyInterleaved(const vector< shared_ptr< CachedFileRange > > &overlapping_ranges, const shared_ptr< CachedFileRange > &new_file_range, data_ptr_t buffer, idx_t nr_bytes, idx_t location, bool actually_read)
Definition duckdb.cpp:388377
BufferHandle TryInsertFileRange(BufferHandle &pin, data_ptr_t &buffer, idx_t nr_bytes, idx_t location, shared_ptr< CachedFileRange > &new_file_range)
Try to insert the file range into the cache.
Definition duckdb.cpp:388324
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read() [2/2]

BufferHandle duckdb::CachingFileHandle::Read ( data_ptr_t & buffer,
idx_t & nr_bytes )

Read (non-seeking) nr bytes from the file (or cache), same as above, also sets nr_bytes to actually read bytes.

388136 {
388137 BufferHandle result;
388138
388139 // If we can't seek, we can't use the cache for these calls,
388140 // because we won't be able to seek over any parts we skipped by reading from the cache
388141 if (!external_file_cache.IsEnabled() || !CanSeek()) {
388142 result = external_file_cache.GetBufferManager().Allocate(MemoryTag::EXTERNAL_FILE_CACHE, nr_bytes);
388143 buffer = result.Ptr();
388144 nr_bytes = NumericCast<idx_t>(GetFileHandle().Read(context, buffer, nr_bytes));
388145 position += NumericCast<idx_t>(nr_bytes);
388146 return result;
388147 }
388148
388149 // Try to read from the cache first
388150 vector<shared_ptr<CachedFileRange>> overlapping_ranges;
388151 {
388152 optional_idx start_location_of_next_range;
388153 result = TryReadFromCache(buffer, nr_bytes, position, overlapping_ranges, start_location_of_next_range);
388154 // start_location_of_next_range is in this case discarded
388155 }
388156
388157 if (result.IsValid()) {
388158 position += nr_bytes;
388159 return result; // Success
388160 }
388161
388162 // Finally, if we weren't able to find the file range in the cache, we have to create a new file range
388163 result = external_file_cache.GetBufferManager().Allocate(MemoryTag::EXTERNAL_FILE_CACHE, nr_bytes);
388164 buffer = result.Ptr();
388165
388166 GetFileHandle().Seek(position);
388167 nr_bytes = NumericCast<idx_t>(GetFileHandle().Read(context, buffer, nr_bytes));
388168 auto new_file_range = make_shared_ptr<CachedFileRange>(result.GetBlockHandle(), nr_bytes, position, version_tag);
388169
388170 result = TryInsertFileRange(result, buffer, nr_bytes, position, new_file_range);
388171 position += NumericCast<idx_t>(nr_bytes);
388172
388173 return result;
388174}
DUCKDB_API BufferHandle Read(data_ptr_t &buffer, idx_t nr_bytes, idx_t location)
Definition duckdb.cpp:388087
Here is the call graph for this function:

◆ GetPath()

string duckdb::CachingFileHandle::GetPath ( ) const

Get some properties of the file.

388176 {
388177 return cached_file.path;
388178}

◆ GetFileSize()

idx_t duckdb::CachingFileHandle::GetFileSize ( )
388180 {
388181 if (file_handle || Validate()) {
388182 return GetFileHandle().GetFileSize();
388183 }
388184 auto guard = cached_file.lock.GetSharedLock();
388185 return cached_file.FileSize(guard);
388186}

◆ GetLastModifiedTime()

timestamp_t duckdb::CachingFileHandle::GetLastModifiedTime ( )
388188 {
388189 if (file_handle || Validate()) {
388190 GetFileHandle();
388191 return last_modified;
388192 }
388193 auto guard = cached_file.lock.GetSharedLock();
388194 return cached_file.LastModified(guard);
388195}

◆ GetVersionTag() [1/2]

string duckdb::CachingFileHandle::GetVersionTag ( )
388197 {
388198 if (file_handle || Validate()) {
388199 GetFileHandle();
388200 return version_tag;
388201 }
388202 auto guard = cached_file.lock.GetSharedLock();
388203 return cached_file.VersionTag(guard);
388204}

◆ Validate()

bool duckdb::CachingFileHandle::Validate ( ) const
388206 {
388207 return ShouldValidate(path, context.GetClientContext(), caching_file_system.db, cached_file.path);
388208}

◆ CanSeek()

bool duckdb::CachingFileHandle::CanSeek ( )
388210 {
388211 if (file_handle || Validate()) {
388212 return GetFileHandle().CanSeek();
388213 }
388214 auto guard = cached_file.lock.GetSharedLock();
388215 return cached_file.CanSeek(guard);
388216}

◆ IsRemoteFile()

bool duckdb::CachingFileHandle::IsRemoteFile ( ) const
388218 {
388220}
static DUCKDB_API bool IsRemoteFile(const string &path)
Whether or not a file is remote or local, based only on file path.
Definition duckdb.cpp:74413

◆ OnDiskFile()

bool duckdb::CachingFileHandle::OnDiskFile ( )
388222 {
388223 if (file_handle || Validate()) {
388224 return GetFileHandle().OnDiskFile();
388225 }
388226 auto guard = cached_file.lock.GetSharedLock();
388227 return cached_file.OnDiskFile(guard);
388228}

◆ SeekPosition()

idx_t duckdb::CachingFileHandle::SeekPosition ( )
388238 {
388239 return position;
388240}

◆ Seek()

void duckdb::CachingFileHandle::Seek ( idx_t location)
388242 {
388243 position = location;
388244 if (file_handle != nullptr) {
388245 file_handle->Seek(location);
388246 }
388247}

◆ GetVersionTag() [2/2]

const string & duckdb::CachingFileHandle::GetVersionTag ( const unique_ptr< StorageLockKey > & guard)
private

Get the version tag of the file (for checking cache invalidation).

388230 {
388231 if (file_handle || Validate()) {
388232 GetFileHandle();
388233 return version_tag;
388234 }
388235 return cached_file.VersionTag(guard);
388236}
Here is the call graph for this function:

◆ TryReadFromCache()

BufferHandle duckdb::CachingFileHandle::TryReadFromCache ( data_ptr_t & buffer,
idx_t nr_bytes,
idx_t location,
vector< shared_ptr< CachedFileRange > > & overlapping_ranges,
optional_idx & start_location_of_next_range )
private

Tries to read from the cache, filling "overlapping_ranges" with ranges that overlap with the request. Returns an invalid BufferHandle if it fails

388251 {
388252 BufferHandle result;
388253
388254 // Get read lock for cached ranges
388255 auto guard = cached_file.lock.GetSharedLock();
388256 auto &ranges = cached_file.Ranges(guard);
388257
388258 // First, try to see if we've read from the exact same location before
388259 auto it = ranges.find(location);
388260 if (it != ranges.end()) {
388261 // We have read from the exact same location before
388262 if (it->second->GetOverlap(nr_bytes, location) == CachedFileRangeOverlap::FULL) {
388263 // The file range contains the requested file range
388264 // FIXME: if we ever start persisting this stuff, this read needs to happen outside of the lock
388265 result = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
388266 if (result.IsValid()) {
388267 return result;
388268 }
388269 }
388270 }
388271
388272 // Second, loop through file ranges (ordered by location) to see if any contain the requested file range
388273 const auto this_end = location + nr_bytes;
388274
388275 // Start at lower_bound (first range with location not less than location of requested range) minus one
388276 // This works because we don't allow fully overlapping ranges in the files
388277 it = ranges.lower_bound(location);
388278 if (it != ranges.begin()) {
388279 --it;
388280 }
388281 while (it != ranges.end()) {
388282 if (it->second->location >= this_end) {
388283 // We're past the requested location, we are going to bail out, save start_location_of_next_range
388284 start_location_of_next_range = it->second->location;
388285 break;
388286 }
388287 // Check if the cached range overlaps the requested one
388288 switch (it->second->GetOverlap(nr_bytes, location)) {
388289 case CachedFileRangeOverlap::NONE:
388290 // No overlap at all
388291 break;
388292 case CachedFileRangeOverlap::PARTIAL:
388293 // Partial overlap, store for potential use later
388294 overlapping_ranges.push_back(it->second);
388295 break;
388296 case CachedFileRangeOverlap::FULL:
388297 // The file range fully contains the requested file range, if the buffer is still valid we're done
388298 // FIXME: if we ever start persisting this stuff, this read needs to happen outside of the lock
388299 result = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
388300 if (result.IsValid()) {
388301 return result;
388302 }
388303 break;
388304 default:
388305 throw InternalException("Unknown CachedFileRangeOverlap");
388306 }
388307 ++it;
388308 }
388309
388310 return result;
388311}
BufferHandle TryReadFromFileRange(const unique_ptr< StorageLockKey > &guard, CachedFileRange &file_range, data_ptr_t &buffer, idx_t nr_bytes, idx_t location)
Try to read from the specified range, return an invalid BufferHandle if it fails.
Definition duckdb.cpp:388313
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryReadFromFileRange()

BufferHandle duckdb::CachingFileHandle::TryReadFromFileRange ( const unique_ptr< StorageLockKey > & guard,
CachedFileRange & file_range,
data_ptr_t & buffer,
idx_t nr_bytes,
idx_t location )
private

Try to read from the specified range, return an invalid BufferHandle if it fails.

388315 {
388316 D_ASSERT(file_range.GetOverlap(nr_bytes, location) == CachedFileRangeOverlap::FULL);
388317 auto result = external_file_cache.GetBufferManager().Pin(file_range.block_handle);
388318 if (result.IsValid()) {
388319 buffer = result.Ptr() + (location - file_range.location);
388320 }
388321 return result;
388322}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TryInsertFileRange()

BufferHandle duckdb::CachingFileHandle::TryInsertFileRange ( BufferHandle & pin,
data_ptr_t & buffer,
idx_t nr_bytes,
idx_t location,
shared_ptr< CachedFileRange > & new_file_range )
private

Try to insert the file range into the cache.

388325 {
388326 // Grab the lock again (write lock this time) to insert the newly created buffer into the ranges
388327 auto guard = cached_file.lock.GetExclusiveLock();
388328 auto &ranges = cached_file.Ranges(guard);
388329
388330 // Start at lower_bound (first range with location not less than location of newly created range)
388331 const auto this_end = location + nr_bytes;
388332 auto it = ranges.lower_bound(location);
388333 if (it != ranges.begin()) {
388334 --it;
388335 }
388336 while (it != ranges.end()) {
388337 if (it->second->location >= this_end) {
388338 // We're past the requested location
388339 break;
388340 }
388341 if (it->second->GetOverlap(*new_file_range) == CachedFileRangeOverlap::FULL) {
388342 // Another thread has read a range that fully contains the requested range in the meantime
388343 auto other_pin = TryReadFromFileRange(guard, *it->second, buffer, nr_bytes, location);
388344 if (other_pin.IsValid()) {
388345 return other_pin;
388346 }
388347 it = ranges.erase(it);
388348 continue;
388349 }
388350 // Check if the new range overlaps with a cached one
388351 switch (new_file_range->GetOverlap(*it->second)) {
388352 case CachedFileRangeOverlap::NONE:
388353 break; // No overlap, still useful
388354 case CachedFileRangeOverlap::PARTIAL:
388355 break; // The newly created range does not fully contain this range, so it is still useful
388356 case CachedFileRangeOverlap::FULL:
388357 // Full overlap, this range will be obsolete when we insert the current one
388358 // Since we have the write lock here, we can do some cleanup
388359 it = ranges.erase(it);
388360 continue;
388361 default:
388362 throw InternalException("Unknown CachedFileRangeOverlap");
388363 }
388364
388365 ++it;
388366 }
388367 D_ASSERT(pin.IsValid());
388368
388369 // Finally, insert newly created buffer into the map
388370 new_file_range->AddCheckSum();
388371 ranges[location] = std::move(new_file_range);
388372 cached_file.Verify(guard);
388373
388374 return std::move(pin);
388375}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadAndCopyInterleaved()

idx_t duckdb::CachingFileHandle::ReadAndCopyInterleaved ( const vector< shared_ptr< CachedFileRange > > & overlapping_ranges,
const shared_ptr< CachedFileRange > & new_file_range,
data_ptr_t buffer,
idx_t nr_bytes,
idx_t location,
bool actually_read )
private

Read from file and copy from cached buffers until the requested read is complete If actually_read is false, no reading happens, only the number of non-cached reads is counted and returned

388379 {
388380 idx_t non_cached_read_count = 0;
388381
388382 idx_t current_location = location;
388383 idx_t remaining_bytes = nr_bytes;
388384 for (auto &overlapping_range : overlapping_ranges) {
388385 D_ASSERT(new_file_range->GetOverlap(*overlapping_range) != CachedFileRangeOverlap::NONE);
388386
388387 if (remaining_bytes == 0) {
388388 break; // All requested bytes were read
388389 }
388390
388391 if (overlapping_range->location > current_location) {
388392 // We need to read from the file until we're at the location of the current overlapping file range
388393 const auto buffer_offset = nr_bytes - remaining_bytes;
388394 const auto bytes_to_read = overlapping_range->location - current_location;
388395 D_ASSERT(bytes_to_read < remaining_bytes);
388396 if (actually_read) {
388397 GetFileHandle().Read(context, buffer + buffer_offset, bytes_to_read, current_location);
388398 }
388399 current_location += bytes_to_read;
388400 remaining_bytes -= bytes_to_read;
388401 non_cached_read_count++;
388402 }
388403
388404 if (overlapping_range->GetOverlap(remaining_bytes, current_location) == CachedFileRangeOverlap::NONE) {
388405 continue; // Remainder does not overlap with the current overlapping file range
388406 }
388407
388408 // Try to pin the current overlapping file range
388409 auto overlapping_file_range_pin = external_file_cache.GetBufferManager().Pin(overlapping_range->block_handle);
388410 if (!overlapping_file_range_pin.IsValid()) {
388411 continue; // No longer valid
388412 }
388413
388414 // Finally, we can copy the data over
388415 D_ASSERT(current_location >= overlapping_range->location);
388416 const auto buffer_offset = nr_bytes - remaining_bytes;
388417 const auto overlapping_range_offset = current_location - overlapping_range->location;
388418 D_ASSERT(overlapping_range->nr_bytes > overlapping_range_offset);
388419 const auto bytes_to_read = MinValue(overlapping_range->nr_bytes - overlapping_range_offset, remaining_bytes);
388420 if (actually_read) {
388421 memcpy(buffer + buffer_offset, overlapping_file_range_pin.Ptr() + overlapping_range_offset, bytes_to_read);
388422 }
388423 current_location += bytes_to_read;
388424 remaining_bytes -= bytes_to_read;
388425 }
388426
388427 // Read the remaining bytes (if any)
388428 if (remaining_bytes != 0) {
388429 const auto buffer_offset = nr_bytes - remaining_bytes;
388430 if (actually_read) {
388431 GetFileHandle().Read(context, buffer + buffer_offset, remaining_bytes, current_location);
388432 }
388433 non_cached_read_count++;
388434 }
388435
388436 return non_cached_read_count;
388437}
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: