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::CachingFileSystemWrapper Class Reference
Inheritance diagram for duckdb::CachingFileSystemWrapper:
Collaboration diagram for duckdb::CachingFileSystemWrapper:

Public Member Functions

DUCKDB_API CachingFileSystemWrapper (FileSystem &file_system, DatabaseInstance &db, CachingMode mode=CachingMode::CACHE_REMOTE_ONLY)
DUCKDB_API CachingFileSystemWrapper (FileSystem &file_system, optional_ptr< FileOpener > file_opener, CachingMode mode=CachingMode::CACHE_REMOTE_ONLY)
DUCKDB_API std::string GetName () const override
 Return the name of the filesytem. Used for forming diagnosis messages.
DUCKDB_API unique_ptr< FileHandle > OpenFile (const string &path, FileOpenFlags flags, optional_ptr< FileOpener > opener=nullptr) override
DUCKDB_API unique_ptr< FileHandle > OpenFile (const OpenFileInfo &path, FileOpenFlags flags, optional_ptr< FileOpener > opener=nullptr)
DUCKDB_API void Read (FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) override
DUCKDB_API void Write (FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) override
DUCKDB_API int64_t Read (FileHandle &handle, void *buffer, int64_t nr_bytes) override
DUCKDB_API int64_t Write (FileHandle &handle, void *buffer, int64_t nr_bytes) override
 Write nr_bytes from the buffer into the file, moving the file pointer forward by nr_bytes.
DUCKDB_API bool Trim (FileHandle &handle, idx_t offset_bytes, idx_t length_bytes) override
DUCKDB_API int64_t GetFileSize (FileHandle &handle) override
 Returns the file size of a file handle, returns -1 on error.
DUCKDB_API timestamp_t GetLastModifiedTime (FileHandle &handle) override
 Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error.
DUCKDB_API string GetVersionTag (FileHandle &handle) override
DUCKDB_API FileType GetFileType (FileHandle &handle) override
 Returns the file type of the attached handle.
DUCKDB_API FileMetadata Stats (FileHandle &handle) override
 Returns the file stats of the attached handle.
DUCKDB_API void Truncate (FileHandle &handle, int64_t new_size) override
DUCKDB_API void FileSync (FileHandle &handle) override
 Sync a file handle to disk.
DUCKDB_API bool DirectoryExists (const string &directory, optional_ptr< FileOpener > opener=nullptr) override
 Check if a directory exists.
DUCKDB_API void CreateDirectory (const string &directory, optional_ptr< FileOpener > opener=nullptr) override
 Create a directory if it does not exist.
DUCKDB_API void CreateDirectoriesRecursive (const string &path, optional_ptr< FileOpener > opener=nullptr) override
 Helper function that uses DirectoryExists and CreateDirectory to ensure all directories in path are created.
DUCKDB_API void RemoveDirectory (const string &directory, optional_ptr< FileOpener > opener=nullptr) override
 Recursively remove a directory and all files in it.
DUCKDB_API bool ListFiles (const string &directory, const std::function< void(const string &, bool)> &callback, FileOpener *opener=nullptr) override
 List files in a directory, invoking the callback method for each one with (filename, is_dir).
DUCKDB_API void MoveFile (const string &source, const string &target, optional_ptr< FileOpener > opener=nullptr) override
DUCKDB_API bool FileExists (const string &filename, optional_ptr< FileOpener > opener=nullptr) override
 Check if a file exists.
DUCKDB_API bool IsPipe (const string &filename, optional_ptr< FileOpener > opener=nullptr) override
 Check if path is pipe.
DUCKDB_API void RemoveFile (const string &filename, optional_ptr< FileOpener > opener=nullptr) override
 Remove a file from disk.
DUCKDB_API bool TryRemoveFile (const string &filename, optional_ptr< FileOpener > opener=nullptr) override
 Remvoe a file from disk if it exists - if it does not exist, return false.
DUCKDB_API string GetHomeDirectory () override
 Gets the users home directory.
DUCKDB_API string ExpandPath (const string &path) override
 Expands a given path, including e.g. expanding the home directory of the user.
DUCKDB_API string PathSeparator (const string &path) override
 Path separator for path.
DUCKDB_API vector< OpenFileInfo > Glob (const string &path, FileOpener *opener=nullptr) override
 Runs a glob on the file system, returning a list of matching files.
DUCKDB_API void RegisterSubSystem (unique_ptr< FileSystem > sub_fs) override
 registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
DUCKDB_API void RegisterSubSystem (FileCompressionType compression_type, unique_ptr< FileSystem > fs) override
DUCKDB_API void UnregisterSubSystem (const string &name) override
 Unregister a sub-filesystem by name.
DUCKDB_API unique_ptr< FileSystem > ExtractSubSystem (const string &name) override
DUCKDB_API vector< string > ListSubSystems () override
 List registered sub-filesystems, including builtin ones.
DUCKDB_API bool CanHandleFile (const string &fpath) override
 Whether or not a sub-system can handle a specific file path.
DUCKDB_API void Seek (FileHandle &handle, idx_t location) override
 Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location.
DUCKDB_API void Reset (FileHandle &handle) override
 Reset a file to the beginning (equivalent to Seek(handle, 0) for simple files).
DUCKDB_API idx_t SeekPosition (FileHandle &handle) override
DUCKDB_API bool IsManuallySet () override
 If FS was manually set by the user.
DUCKDB_API bool CanSeek () override
 Whether or not we can seek into the file.
DUCKDB_API bool OnDiskFile (FileHandle &handle) override
DUCKDB_API unique_ptr< FileHandle > OpenCompressedFile (QueryContext context, unique_ptr< FileHandle > handle, bool write) override
DUCKDB_API void SetDisabledFileSystems (const vector< string > &names) override
DUCKDB_API bool SubSystemIsDisabled (const string &name) override
DUCKDB_API bool IsDisabledForPath (const string &path) override
 Check if the filesystem that would handle this path is disabled.
Public Member Functions inherited from duckdb::FileSystem
DUCKDB_API unique_ptr< FileHandle > OpenFile (const OpenFileInfo &path, FileOpenFlags flags, optional_ptr< FileOpener > opener=nullptr)
DUCKDB_API bool ListFiles (const string &directory, const std::function< void(OpenFileInfo &info)> &callback, optional_ptr< FileOpener > opener=nullptr)
virtual DUCKDB_API void RemoveFiles (const vector< string > &filenames, optional_ptr< FileOpener > opener=nullptr)
 Remove multiple files from disk - does not error if any file does not exist.
virtual DUCKDB_API bool IsPathAbsolute (const string &path)
 Checks if path is is an absolute path.
DUCKDB_API string JoinPath (const string &a, const string &path)
 Join two paths together.
template<typename... ARGS>
string JoinPath (const string &a, const string &b, ARGS... args)
DUCKDB_API string ConvertSeparators (const string &path)
 Convert separators in a path to the local separators (e.g. convert "/" into \ on windows).
DUCKDB_API string ExtractBaseName (const string &path)
 Extract the base name of a file (e.g. if the input is lib/example.dll the base name is 'example').
DUCKDB_API string ExtractExtension (const string &path)
 Extract the extension of a file (e.g. if the input is lib/example.dll the extension is 'dll').
DUCKDB_API string ExtractName (const string &path)
 Extract the name of a file (e.g if the input is lib/example.dll the name is 'example.dll').
DUCKDB_API unique_ptr< MultiFileList > Glob (const string &path, const FileGlobInput &input, optional_ptr< FileOpener > opener)
DUCKDB_API unique_ptr< MultiFileList > GlobFileList (const string &path, const FileGlobInput &input=FileGlobOptions::DISALLOW_EMPTY)
DUCKDB_API vector< OpenFileInfo > GlobFiles (const string &pattern, const FileGlobInput &input=FileGlobOptions::DISALLOW_EMPTY)
virtual DUCKDB_API string CanonicalizePath (const string &path, optional_ptr< FileOpener > opener=nullptr)
 Canonicalize a path.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const
Public Member Functions inherited from duckdb::enable_shared_from_this< CachingFileSystemWrapper >
shared_ptr< CachingFileSystemWrapper > shared_from_this ()

Protected Member Functions

DUCKDB_API unique_ptr< FileHandle > OpenFileExtended (const OpenFileInfo &path, FileOpenFlags flags, optional_ptr< FileOpener > opener) override
DUCKDB_API bool SupportsOpenFileExtended () const override
DUCKDB_API bool ListFilesExtended (const string &directory, const std::function< void(OpenFileInfo &info)> &callback, optional_ptr< FileOpener > opener) override
DUCKDB_API bool SupportsListFilesExtended () const override
Protected Member Functions inherited from duckdb::FileSystem
virtual DUCKDB_API unique_ptr< MultiFileList > GlobFilesExtended (const string &path, const FileGlobInput &input, optional_ptr< FileOpener > opener=nullptr)
virtual DUCKDB_API bool SupportsGlobExtended () const
Protected Member Functions inherited from duckdb::enable_shared_from_this< CachingFileSystemWrapper >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept

Private Member Functions

bool ShouldUseCache (const string &path) const
CachingFileHandle * GetCachingHandleIfPossible (FileHandle &handle)

Private Attributes

CachingFileSystem caching_file_system
FileSystem & underlying_file_system
CachingMode caching_mode

Additional Inherited Members

Static Public Member Functions inherited from duckdb::FileSystem
static DUCKDB_API FileSystem & GetFileSystem (ClientContext &context)
static DUCKDB_API FileSystem & GetFileSystem (DatabaseInstance &db)
static DUCKDB_API FileSystem & Get (AttachedDatabase &db)
static DUCKDB_API void SetWorkingDirectory (const string &path)
 Sets the working directory.
static DUCKDB_API string GetWorkingDirectory ()
 Gets the working directory.
static DUCKDB_API string GetHomeDirectory (optional_ptr< FileOpener > opener)
 Gets the users home directory.
static DUCKDB_API string ExpandPath (const string &path, optional_ptr< FileOpener > opener)
 Expands a given path, including e.g. expanding the home directory of the user.
static DUCKDB_API optional_idx GetAvailableMemory ()
 Returns the system-available memory in bytes. Returns DConstants::INVALID_INDEX if the system function fails.
static DUCKDB_API optional_idx GetAvailableDiskSpace (const string &path)
 Returns the space available on the disk. Returns DConstants::INVALID_INDEX if the information was not available.
static DUCKDB_API string GetEnvVariable (const string &name)
 Returns the value of an environment variable - or the empty string if it is not set.
static DUCKDB_API bool HasGlob (const string &str)
 Whether there is a glob in the string.
static DUCKDB_API unique_ptr< FileSystem > CreateLocal ()
 Create a LocalFileSystem.
static DUCKDB_API bool IsRemoteFile (const string &path)
 Whether or not a file is remote or local, based only on file path.
static DUCKDB_API bool IsRemoteFile (const string &path, string &extension)
static DUCKDB_API bool IsDirectory (const OpenFileInfo &info)

Detailed Description

[CachingFileSystemWrapper] is an adapter class, which wraps [CachingFileSystem] to conform to FileSystem API. Different from [CachingFileSystem], which owns cache content and returns a [BufferHandle] to achieve zero-copy on read, the wrapper class always copies requested byted into the provided address.

NOTICE: Currently only read and seek operations are supported, write operations are disabled.

Constructor & Destructor Documentation

◆ CachingFileSystemWrapper() [1/2]

duckdb::CachingFileSystemWrapper::CachingFileSystemWrapper ( FileSystem & file_system,
DatabaseInstance & db,
CachingMode mode = CachingMode::CACHE_REMOTE_ONLY )
388487 : caching_file_system(file_system, db), underlying_file_system(file_system), caching_mode(mode) {
388488}

◆ CachingFileSystemWrapper() [2/2]

duckdb::CachingFileSystemWrapper::CachingFileSystemWrapper ( FileSystem & file_system,
optional_ptr< FileOpener > file_opener,
CachingMode mode = CachingMode::CACHE_REMOTE_ONLY )
388492 : caching_file_system(file_system, GetDatabaseInstance(file_opener)), underlying_file_system(file_system),
388493 caching_mode(mode) {
388494}

◆ ~CachingFileSystemWrapper()

duckdb::CachingFileSystemWrapper::~CachingFileSystemWrapper ( )
override
388516 {
388517}

Member Function Documentation

◆ GetName()

std::string duckdb::CachingFileSystemWrapper::GetName ( ) const
overridevirtual

Return the name of the filesytem. Used for forming diagnosis messages.

Implements duckdb::FileSystem.

388519 {
388520 return "CachingFileSystemWrapper";
388521}

◆ OpenFile() [1/2]

unique_ptr< FileHandle > duckdb::CachingFileSystemWrapper::OpenFile ( const string & path,
FileOpenFlags flags,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Reimplemented from duckdb::FileSystem.

388555 {
388556 return OpenFile(OpenFileInfo(path), flags, opener);
388557}

◆ OpenFile() [2/2]

unique_ptr< FileHandle > duckdb::CachingFileSystemWrapper::OpenFile ( const OpenFileInfo & path,
FileOpenFlags flags,
optional_ptr< FileOpener > opener = nullptr )
388560 {
388561 if (SupportsOpenFileExtended()) {
388562 return OpenFileExtended(path, flags, opener);
388563 }
388564 throw NotImplementedException("CachingFileSystemWrapper: OpenFile is not implemented!");
388565}

◆ Read() [1/2]

void duckdb::CachingFileSystemWrapper::Read ( FileHandle & handle,
void * buffer,
int64_t nr_bytes,
idx_t location )
overridevirtual

Read exactly nr_bytes from the specified location in the file. Fails if nr_bytes could not be read. This is equivalent to calling SetFilePointer(location) followed by calling Read().

Reimplemented from duckdb::FileSystem.

388593 {
388594 auto *caching_handle = GetCachingHandleIfPossible(handle);
388595 if (!caching_handle) {
388596 return underlying_file_system.Read(handle, buffer, nr_bytes, location);
388597 }
388598
388599 data_ptr_t cached_buffer = nullptr;
388600 auto buffer_handle = caching_handle->Read(cached_buffer, NumericCast<idx_t>(nr_bytes), location);
388601 if (!buffer_handle.IsValid()) {
388602 throw IOException("Failed to read from caching file handle: file=\"%s\", offset=%llu, bytes=%lld",
388603 handle.GetPath().c_str(), location, nr_bytes);
388604 }
388605
388606 // Copy data from cached buffer handle to user's buffer.
388607 memcpy(buffer, cached_buffer, NumericCast<size_t>(nr_bytes));
388608}
Here is the caller graph for this function:

◆ Write() [1/2]

void duckdb::CachingFileSystemWrapper::Write ( FileHandle & handle,
void * buffer,
int64_t nr_bytes,
idx_t location )
overridevirtual

Write exactly nr_bytes to the specified location in the file. Fails if nr_bytes could not be written. This is equivalent to calling SetFilePointer(location) followed by calling Write().

Reimplemented from duckdb::FileSystem.

388526 {
388527 throw NotImplementedException("CachingFileSystemWrapper: Write operations are not supported. "
388528 "CachingFileSystemWrapper is a read-only caching filesystem.");
388529}

◆ Read() [2/2]

int64_t duckdb::CachingFileSystemWrapper::Read ( FileHandle & handle,
void * buffer,
int64_t nr_bytes )
overridevirtual

Read nr_bytes from the specified file into the buffer, moving the file pointer forward by nr_bytes. Returns the amount of bytes read.

Reimplemented from duckdb::FileSystem.

388610 {
388611 const idx_t current_position = SeekPosition(handle);
388612 const idx_t max_read = GetFileSize(handle) - current_position;
388613 nr_bytes = MinValue<int64_t>(NumericCast<int64_t>(max_read), nr_bytes);
388614 Read(handle, buffer, nr_bytes, current_position);
388615 Seek(handle, current_position + NumericCast<idx_t>(nr_bytes));
388616 return nr_bytes;
388617}
DUCKDB_API int64_t GetFileSize(FileHandle &handle) override
Returns the file size of a file handle, returns -1 on error.
Definition duckdb.cpp:388622
DUCKDB_API void Seek(FileHandle &handle, idx_t location) override
Set the file pointer of a file handle to a specified location. Reads and writes will happen from this...
Definition duckdb.cpp:388775
DUCKDB_API void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location) override
Definition duckdb.cpp:388593
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:

◆ Write() [2/2]

int64_t duckdb::CachingFileSystemWrapper::Write ( FileHandle & handle,
void * buffer,
int64_t nr_bytes )
overridevirtual

Write nr_bytes from the buffer into the file, moving the file pointer forward by nr_bytes.

Reimplemented from duckdb::FileSystem.

388531 {
388532 throw NotImplementedException("CachingFileSystemWrapper: Write operations are not supported. "
388533 "CachingFileSystemWrapper is a read-only caching filesystem.");
388534}

◆ Trim()

bool duckdb::CachingFileSystemWrapper::Trim ( FileHandle & handle,
idx_t offset_bytes,
idx_t length_bytes )
overridevirtual

Excise a range of the file. The OS can drop pages from the page-cache, and the file-system is free to deallocate this range (sparse file support). Reads to the range will succeed but will return undefined data.

Reimplemented from duckdb::FileSystem.

388536 {
388537 throw NotImplementedException("CachingFileSystemWrapper: Trim operations are not supported. "
388538 "CachingFileSystemWrapper is a read-only caching filesystem.");
388539}

◆ GetFileSize()

int64_t duckdb::CachingFileSystemWrapper::GetFileSize ( FileHandle & handle)
overridevirtual

Returns the file size of a file handle, returns -1 on error.

Reimplemented from duckdb::FileSystem.

388622 {
388623 auto *caching_handle = GetCachingHandleIfPossible(handle);
388624 if (!caching_handle) {
388625 return underlying_file_system.GetFileSize(handle);
388626 }
388627
388628 return NumericCast<int64_t>(caching_handle->GetFileSize());
388629}
Here is the caller graph for this function:

◆ GetLastModifiedTime()

timestamp_t duckdb::CachingFileSystemWrapper::GetLastModifiedTime ( FileHandle & handle)
overridevirtual

Returns the file last modified time of a file handle, returns timespec with zero on all attributes on error.

Reimplemented from duckdb::FileSystem.

388631 {
388632 auto *caching_handle = GetCachingHandleIfPossible(handle);
388633 if (!caching_handle) {
388634 return underlying_file_system.GetLastModifiedTime(handle);
388635 }
388636
388637 return caching_handle->GetLastModifiedTime();
388638}

◆ GetVersionTag()

string duckdb::CachingFileSystemWrapper::GetVersionTag ( FileHandle & handle)
overridevirtual

Returns a tag that uniquely identifies the version of the file, used for checking cache invalidation for CachingFileSystem httpfs files

Reimplemented from duckdb::FileSystem.

388640 {
388641 auto *caching_handle = GetCachingHandleIfPossible(handle);
388642 if (!caching_handle) {
388643 return underlying_file_system.GetVersionTag(handle);
388644 }
388645
388646 return caching_handle->GetVersionTag();
388647}

◆ GetFileType()

FileType duckdb::CachingFileSystemWrapper::GetFileType ( FileHandle & handle)
overridevirtual

Returns the file type of the attached handle.

Reimplemented from duckdb::FileSystem.

388649 {
388650 auto *caching_handle = GetCachingHandleIfPossible(handle);
388651 if (!caching_handle) {
388652 return underlying_file_system.GetFileType(handle);
388653 }
388654
388655 auto &file_handle = caching_handle->GetFileHandle();
388656 return underlying_file_system.GetFileType(file_handle);
388657}

◆ Stats()

FileMetadata duckdb::CachingFileSystemWrapper::Stats ( FileHandle & handle)
overridevirtual

Returns the file stats of the attached handle.

Reimplemented from duckdb::FileSystem.

388659 {
388660 auto *caching_handle = GetCachingHandleIfPossible(handle);
388661 if (!caching_handle) {
388662 return underlying_file_system.Stats(handle);
388663 }
388664
388665 auto &file_handle = caching_handle->GetFileHandle();
388666 return underlying_file_system.Stats(file_handle);
388667}

◆ Truncate()

void duckdb::CachingFileSystemWrapper::Truncate ( FileHandle & handle,
int64_t new_size )
overridevirtual

Truncate a file to a maximum size of new_size, new_size should be smaller than or equal to the current size of the file

Reimplemented from duckdb::FileSystem.

388541 {
388542 throw NotImplementedException("CachingFileSystemWrapper: Truncate operations are not supported. "
388543 "CachingFileSystemWrapper is a read-only caching filesystem.");
388544}

◆ FileSync()

void duckdb::CachingFileSystemWrapper::FileSync ( FileHandle & handle)
overridevirtual

Sync a file handle to disk.

Reimplemented from duckdb::FileSystem.

388546 {
388547 throw NotImplementedException("CachingFileSystemWrapper: FileSync operations are not supported. "
388548 "CachingFileSystemWrapper is a read-only caching filesystem.");
388549}

◆ DirectoryExists()

bool duckdb::CachingFileSystemWrapper::DirectoryExists ( const string & directory,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Check if a directory exists.

Reimplemented from duckdb::FileSystem.

388672 {
388673 return underlying_file_system.DirectoryExists(directory, opener);
388674}

◆ CreateDirectory()

void duckdb::CachingFileSystemWrapper::CreateDirectory ( const string & directory,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Create a directory if it does not exist.

Reimplemented from duckdb::FileSystem.

388676 {
388677 underlying_file_system.CreateDirectory(directory, opener);
388678}

◆ CreateDirectoriesRecursive()

void duckdb::CachingFileSystemWrapper::CreateDirectoriesRecursive ( const string & path,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Helper function that uses DirectoryExists and CreateDirectory to ensure all directories in path are created.

Reimplemented from duckdb::FileSystem.

388680 {
388681 underlying_file_system.CreateDirectoriesRecursive(path, opener);
388682}

◆ RemoveDirectory()

void duckdb::CachingFileSystemWrapper::RemoveDirectory ( const string & directory,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Recursively remove a directory and all files in it.

Reimplemented from duckdb::FileSystem.

388684 {
388685 underlying_file_system.RemoveDirectory(directory, opener);
388686}

◆ ListFiles()

bool duckdb::CachingFileSystemWrapper::ListFiles ( const string & directory,
const std::function< void(const string &, bool)> & callback,
FileOpener * opener = nullptr )
overridevirtual

List files in a directory, invoking the callback method for each one with (filename, is_dir).

Reimplemented from duckdb::FileSystem.

388690 {
388691 return underlying_file_system.ListFiles(directory, callback, opener);
388692}

◆ MoveFile()

void duckdb::CachingFileSystemWrapper::MoveFile ( const string & source,
const string & target,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Move a file from source path to the target, StorageManager relies on this being an atomic action for ACID properties

Reimplemented from duckdb::FileSystem.

388706 {
388707 underlying_file_system.MoveFile(source, target, opener);
388708}

◆ FileExists()

bool duckdb::CachingFileSystemWrapper::FileExists ( const string & filename,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Check if a file exists.

Reimplemented from duckdb::FileSystem.

388710 {
388711 return underlying_file_system.FileExists(filename, opener);
388712}

◆ IsPipe()

bool duckdb::CachingFileSystemWrapper::IsPipe ( const string & filename,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Check if path is pipe.

Reimplemented from duckdb::FileSystem.

388714 {
388715 return underlying_file_system.IsPipe(filename, opener);
388716}

◆ RemoveFile()

void duckdb::CachingFileSystemWrapper::RemoveFile ( const string & filename,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Remove a file from disk.

Reimplemented from duckdb::FileSystem.

388718 {
388719 underlying_file_system.RemoveFile(filename, opener);
388720}

◆ TryRemoveFile()

bool duckdb::CachingFileSystemWrapper::TryRemoveFile ( const string & filename,
optional_ptr< FileOpener > opener = nullptr )
overridevirtual

Remvoe a file from disk if it exists - if it does not exist, return false.

Reimplemented from duckdb::FileSystem.

388722 {
388723 return underlying_file_system.TryRemoveFile(filename, opener);
388724}

◆ GetHomeDirectory()

string duckdb::CachingFileSystemWrapper::GetHomeDirectory ( )
overridevirtual

Gets the users home directory.

Reimplemented from duckdb::FileSystem.

388729 {
388730 return underlying_file_system.GetHomeDirectory();
388731}

◆ ExpandPath()

string duckdb::CachingFileSystemWrapper::ExpandPath ( const string & path)
overridevirtual

Expands a given path, including e.g. expanding the home directory of the user.

Reimplemented from duckdb::FileSystem.

388733 {
388734 return underlying_file_system.ExpandPath(path);
388735}

◆ PathSeparator()

string duckdb::CachingFileSystemWrapper::PathSeparator ( const string & path)
overridevirtual

Path separator for path.

Reimplemented from duckdb::FileSystem.

388737 {
388738 return underlying_file_system.PathSeparator(path);
388739}

◆ Glob()

vector< OpenFileInfo > duckdb::CachingFileSystemWrapper::Glob ( const string & path,
FileOpener * opener = nullptr )
overridevirtual

Runs a glob on the file system, returning a list of matching files.

Reimplemented from duckdb::FileSystem.

388741 {
388742 return underlying_file_system.Glob(path, opener);
388743}

◆ RegisterSubSystem() [1/2]

void duckdb::CachingFileSystemWrapper::RegisterSubSystem ( unique_ptr< FileSystem > sub_fs)
overridevirtual

registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.

Reimplemented from duckdb::FileSystem.

388748 {
388749 underlying_file_system.RegisterSubSystem(std::move(sub_fs));
388750}

◆ RegisterSubSystem() [2/2]

void duckdb::CachingFileSystemWrapper::RegisterSubSystem ( FileCompressionType compression_type,
unique_ptr< FileSystem > fs )
overridevirtual

Reimplemented from duckdb::FileSystem.

388752 {
388753 underlying_file_system.RegisterSubSystem(compression_type, std::move(fs));
388754}

◆ UnregisterSubSystem()

void duckdb::CachingFileSystemWrapper::UnregisterSubSystem ( const string & name)
overridevirtual

Unregister a sub-filesystem by name.

Reimplemented from duckdb::FileSystem.

388756 {
388757 underlying_file_system.UnregisterSubSystem(name);
388758}

◆ ExtractSubSystem()

unique_ptr< FileSystem > duckdb::CachingFileSystemWrapper::ExtractSubSystem ( const string & name)
overridevirtual

Reimplemented from duckdb::FileSystem.

388760 {
388761 return underlying_file_system.ExtractSubSystem(name);
388762}

◆ ListSubSystems()

vector< string > duckdb::CachingFileSystemWrapper::ListSubSystems ( )
overridevirtual

List registered sub-filesystems, including builtin ones.

Reimplemented from duckdb::FileSystem.

388764 {
388765 return underlying_file_system.ListSubSystems();
388766}

◆ CanHandleFile()

bool duckdb::CachingFileSystemWrapper::CanHandleFile ( const string & fpath)
overridevirtual

Whether or not a sub-system can handle a specific file path.

Reimplemented from duckdb::FileSystem.

388768 {
388769 return underlying_file_system.CanHandleFile(fpath);
388770}

◆ Seek()

void duckdb::CachingFileSystemWrapper::Seek ( FileHandle & handle,
idx_t location )
overridevirtual

Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location.

Reimplemented from duckdb::FileSystem.

388775 {
388776 auto *caching_handle = GetCachingHandleIfPossible(handle);
388777 if (!caching_handle) {
388778 return underlying_file_system.Seek(handle, location);
388779 }
388780
388781 caching_handle->Seek(location);
388782}
Here is the caller graph for this function:

◆ Reset()

void duckdb::CachingFileSystemWrapper::Reset ( FileHandle & handle)
overridevirtual

Reset a file to the beginning (equivalent to Seek(handle, 0) for simple files).

Reimplemented from duckdb::FileSystem.

388784 {
388785 Seek(handle, 0);
388786}
Here is the call graph for this function:

◆ SeekPosition()

idx_t duckdb::CachingFileSystemWrapper::SeekPosition ( FileHandle & handle)
overridevirtual

Reimplemented from duckdb::FileSystem.

388788 {
388789 auto *caching_handle = GetCachingHandleIfPossible(handle);
388790 if (!caching_handle) {
388791 return underlying_file_system.SeekPosition(handle);
388792 }
388793
388794 return caching_handle->SeekPosition();
388795}

◆ IsManuallySet()

bool duckdb::CachingFileSystemWrapper::IsManuallySet ( )
overridevirtual

If FS was manually set by the user.

Reimplemented from duckdb::FileSystem.

388797 {
388798 return underlying_file_system.IsManuallySet();
388799}

◆ CanSeek()

bool duckdb::CachingFileSystemWrapper::CanSeek ( )
overridevirtual

Whether or not we can seek into the file.

Reimplemented from duckdb::FileSystem.

388801 {
388802 return underlying_file_system.CanSeek();
388803}

◆ OnDiskFile()

bool duckdb::CachingFileSystemWrapper::OnDiskFile ( FileHandle & handle)
overridevirtual

Whether or not the FS handles plain files on disk. This is relevant for certain optimizations, as random reads in a file on-disk are much cheaper than e.g. random reads in a file over the network

Reimplemented from duckdb::FileSystem.

388805 {
388806 auto *caching_handle = GetCachingHandleIfPossible(handle);
388807 if (!caching_handle) {
388808 return underlying_file_system.OnDiskFile(handle);
388809 }
388810
388811 return caching_handle->OnDiskFile();
388812}

◆ OpenCompressedFile()

unique_ptr< FileHandle > duckdb::CachingFileSystemWrapper::OpenCompressedFile ( QueryContext context,
unique_ptr< FileHandle > handle,
bool write )
overridevirtual

Reimplemented from duckdb::FileSystem.

388818 {
388819 return underlying_file_system.OpenCompressedFile(context, std::move(handle), write);
388820}

◆ SetDisabledFileSystems()

void duckdb::CachingFileSystemWrapper::SetDisabledFileSystems ( const vector< string > & names)
overridevirtual

Reimplemented from duckdb::FileSystem.

388822 {
388823 underlying_file_system.SetDisabledFileSystems(names);
388824}

◆ SubSystemIsDisabled()

bool duckdb::CachingFileSystemWrapper::SubSystemIsDisabled ( const string & name)
overridevirtual

Reimplemented from duckdb::FileSystem.

388826 {
388827 return underlying_file_system.SubSystemIsDisabled(name);
388828}

◆ IsDisabledForPath()

bool duckdb::CachingFileSystemWrapper::IsDisabledForPath ( const string & path)
overridevirtual

Check if the filesystem that would handle this path is disabled.

Reimplemented from duckdb::FileSystem.

388830 {
388831 return underlying_file_system.IsDisabledForPath(path);
388832}

◆ OpenFileExtended()

unique_ptr< FileHandle > duckdb::CachingFileSystemWrapper::OpenFileExtended ( const OpenFileInfo & path,
FileOpenFlags flags,
optional_ptr< FileOpener > opener )
overrideprotectedvirtual

Reimplemented from duckdb::FileSystem.

388568 {
388569 if (flags.OpenForWriting()) {
388570 throw NotImplementedException("CachingFileSystemWrapper: Cannot open file for writing. "
388571 "CachingFileSystemWrapper is a read-only caching filesystem.");
388572 }
388573 if (!flags.OpenForReading()) {
388574 throw NotImplementedException("CachingFileSystemWrapper: File must be opened for reading. "
388575 "CachingFileSystemWrapper is a read-only caching filesystem.");
388576 }
388577
388578 if (ShouldUseCache(path.path)) {
388579 auto caching_handle = caching_file_system.OpenFile(path, flags, opener);
388580 return make_uniq<CachingFileHandleWrapper>(shared_from_this(), std::move(caching_handle), flags);
388581 }
388582 // Bypass cache, use underlying file system directly.
388583 return underlying_file_system.OpenFile(path, flags, opener);
388584}

◆ SupportsOpenFileExtended()

bool duckdb::CachingFileSystemWrapper::SupportsOpenFileExtended ( ) const
overrideprotectedvirtual

Reimplemented from duckdb::FileSystem.

388586 {
388587 return true;
388588}

◆ ListFilesExtended()

bool duckdb::CachingFileSystemWrapper::ListFilesExtended ( const string & directory,
const std::function< void(OpenFileInfo &info)> & callback,
optional_ptr< FileOpener > opener )
overrideprotectedvirtual

Reimplemented from duckdb::FileSystem.

388696 {
388697 // Use the public ListFiles API which will internally call `ListFilesExtended` if supported.
388698 return underlying_file_system.ListFiles(directory, callback, opener);
388699}

◆ SupportsListFilesExtended()

bool duckdb::CachingFileSystemWrapper::SupportsListFilesExtended ( ) const
overrideprotectedvirtual

Reimplemented from duckdb::FileSystem.

388701 {
388702 // Cannot delegate to internal filesystem's invocaton since it's `protected`.
388703 return true;
388704}

◆ ShouldUseCache()

bool duckdb::CachingFileSystemWrapper::ShouldUseCache ( const string & path) const
private
388496 {
388497 if (caching_mode == CachingMode::ALWAYS_CACHE) {
388498 return true;
388499 }
388500 if (caching_mode == CachingMode::NO_CACHING) {
388501 return false;
388502 }
388503 D_ASSERT(caching_mode == CachingMode::CACHE_REMOTE_ONLY);
388504 return FileSystem::IsRemoteFile(path);
388505}
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

◆ GetCachingHandleIfPossible()

CachingFileHandle * duckdb::CachingFileSystemWrapper::GetCachingHandleIfPossible ( FileHandle & handle)
private
388507 {
388508 const auto &filepath = handle.GetPath();
388509 if (!ShouldUseCache(filepath)) {
388510 return nullptr;
388511 }
388512 auto &wrapper = handle.Cast<CachingFileHandleWrapper>();
388513 return wrapper.caching_handle.get();
388514}

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