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::FileHandle Struct Referenceabstract
Inheritance diagram for duckdb::FileHandle:
Collaboration diagram for duckdb::FileHandle:

Public Member Functions

DUCKDB_API FileHandle (FileSystem &file_system, string path, FileOpenFlags flags)
 
 FileHandle (const FileHandle &)=delete
 
DUCKDB_API int64_t Read (void *buffer, idx_t nr_bytes)
 
DUCKDB_API int64_t Read (QueryContext context, void *buffer, idx_t nr_bytes)
 
DUCKDB_API int64_t Write (void *buffer, idx_t nr_bytes)
 
DUCKDB_API int64_t Write (QueryContext context, void *buffer, idx_t nr_bytes)
 
DUCKDB_API void Read (void *buffer, idx_t nr_bytes, idx_t location)
 
DUCKDB_API void Read (QueryContext context, void *buffer, idx_t nr_bytes, idx_t location)
 
DUCKDB_API void Write (QueryContext context, void *buffer, idx_t nr_bytes, idx_t location)
 
DUCKDB_API void Seek (idx_t location)
 
DUCKDB_API void Reset ()
 
DUCKDB_API idx_t SeekPosition ()
 
DUCKDB_API void Sync ()
 
DUCKDB_API void Truncate (int64_t new_size)
 
DUCKDB_API string ReadLine ()
 
DUCKDB_API string ReadLine (QueryContext context)
 
DUCKDB_API bool Trim (idx_t offset_bytes, idx_t length_bytes)
 
virtual DUCKDB_API idx_t GetProgress ()
 
virtual DUCKDB_API FileCompressionType GetFileCompressionType ()
 
DUCKDB_API bool CanSeek ()
 
DUCKDB_API bool IsPipe ()
 
DUCKDB_API bool OnDiskFile ()
 
DUCKDB_API idx_t GetFileSize ()
 
DUCKDB_API FileType GetType ()
 
DUCKDB_API FileMetadata Stats ()
 
DUCKDB_API void TryAddLogger (FileOpener &opener)
 
virtual DUCKDB_API void Close ()=0
 Closes the file handle.
 
string GetPath () const
 
FileOpenFlags GetFlags () const
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Public Attributes

FileSystemfile_system
 
string path
 
FileOpenFlags flags
 
shared_ptr< Loggerlogger
 

Constructor & Destructor Documentation

◆ FileHandle()

duckdb::FileHandle::FileHandle ( FileSystem file_system,
string  path,
FileOpenFlags  flags 
)
74262 : file_system(file_system), path(std::move(path_p)), flags(flags) {
74263}

◆ ~FileHandle()

duckdb::FileHandle::~FileHandle ( )
virtual
74265 {
74266}

Member Function Documentation

◆ Read() [1/4]

int64_t duckdb::FileHandle::Read ( void buffer,
idx_t  nr_bytes 
)
74268 {
74269 return file_system.Read(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes));
74270}
virtual DUCKDB_API void Read(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location)
Definition duckdb.cpp:73967

◆ Read() [2/4]

int64_t duckdb::FileHandle::Read ( QueryContext  context,
void buffer,
idx_t  nr_bytes 
)
74272 {
74273 if (context.GetClientContext() != nullptr) {
74274 context.GetClientContext()->client_data->profiler->AddToCounter(MetricType::TOTAL_BYTES_READ, nr_bytes);
74275 }
74276
74277 return file_system.Read(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes));
74278}

◆ Write() [1/3]

int64_t duckdb::FileHandle::Write ( void buffer,
idx_t  nr_bytes 
)
74284 {
74285 return file_system.Write(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes));
74286}
virtual DUCKDB_API void Write(FileHandle &handle, void *buffer, int64_t nr_bytes, idx_t location)
Definition duckdb.cpp:73971

◆ Write() [2/3]

int64_t duckdb::FileHandle::Write ( QueryContext  context,
void buffer,
idx_t  nr_bytes 
)
74288 {
74289 if (context.GetClientContext() != nullptr) {
74290 context.GetClientContext()->client_data->profiler->AddToCounter(MetricType::TOTAL_BYTES_WRITTEN, nr_bytes);
74291 }
74292
74293 return file_system.Write(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes));
74294}

◆ Read() [3/4]

void duckdb::FileHandle::Read ( void buffer,
idx_t  nr_bytes,
idx_t  location 
)
74296 {
74297 file_system.Read(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes), location);
74298}

◆ Read() [4/4]

void duckdb::FileHandle::Read ( QueryContext  context,
void buffer,
idx_t  nr_bytes,
idx_t  location 
)
74300 {
74301 if (context.GetClientContext() != nullptr) {
74302 context.GetClientContext()->client_data->profiler->AddToCounter(MetricType::TOTAL_BYTES_READ, nr_bytes);
74303 }
74304
74305 file_system.Read(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes), location);
74306}

◆ Write() [3/3]

void duckdb::FileHandle::Write ( QueryContext  context,
void buffer,
idx_t  nr_bytes,
idx_t  location 
)
74308 {
74309 if (context.GetClientContext() != nullptr) {
74310 context.GetClientContext()->client_data->profiler->AddToCounter(MetricType::TOTAL_BYTES_WRITTEN, nr_bytes);
74311 }
74312
74313 file_system.Write(*this, buffer, UnsafeNumericCast<int64_t>(nr_bytes), location);
74314}

◆ Seek()

void duckdb::FileHandle::Seek ( idx_t  location)
74316 {
74317 file_system.Seek(*this, location);
74318}
virtual DUCKDB_API void Seek(FileHandle &handle, idx_t location)
Set the file pointer of a file handle to a specified location. Reads and writes will happen from this...
Definition duckdb.cpp:74232

◆ Reset()

void duckdb::FileHandle::Reset ( )
74320 {
74321 file_system.Reset(*this);
74322}
virtual DUCKDB_API void Reset(FileHandle &handle)
Reset a file to the beginning (equivalent to Seek(handle, 0) for simple files)
Definition duckdb.cpp:74236

◆ SeekPosition()

idx_t duckdb::FileHandle::SeekPosition ( )
74324 {
74325 return file_system.SeekPosition(*this);
74326}

◆ Sync()

void duckdb::FileHandle::Sync ( )
74376 {
74377 file_system.FileSync(*this);
74378}
virtual DUCKDB_API void FileSync(FileHandle &handle)
Sync a file handle to disk.
Definition duckdb.cpp:74126

◆ Truncate()

void duckdb::FileHandle::Truncate ( int64_t  new_size)
74380 {
74381 file_system.Truncate(*this, new_size);
74382}
virtual DUCKDB_API void Truncate(FileHandle &handle, int64_t new_size)
Definition duckdb.cpp:74009

◆ ReadLine() [1/2]

string duckdb::FileHandle::ReadLine ( )
74340 {
74341 string result;
74342 char buffer[1];
74343 while (true) {
74344 auto tuples_read = UnsafeNumericCast<idx_t>(Read(buffer, 1));
74345 if (tuples_read == 0 || buffer[0] == '\n') {
74346 return result;
74347 }
74348 if (buffer[0] != '\r') {
74349 result += buffer[0];
74350 }
74351 }
74352}

◆ ReadLine() [2/2]

string duckdb::FileHandle::ReadLine ( QueryContext  context)
74354 {
74355 string result;
74356 char buffer[1];
74357 while (true) {
74358 auto tuples_read = UnsafeNumericCast<idx_t>(Read(context, buffer, 1));
74359 if (tuples_read == 0 || buffer[0] == '\n') {
74360 return result;
74361 }
74362 if (buffer[0] != '\r') {
74363 result += buffer[0];
74364 }
74365 }
74366}

◆ Trim()

bool duckdb::FileHandle::Trim ( idx_t  offset_bytes,
idx_t  length_bytes 
)
74280 {
74281 return file_system.Trim(*this, offset_bytes, length_bytes);
74282}
virtual DUCKDB_API bool Trim(FileHandle &handle, idx_t offset_bytes, idx_t length_bytes)
Definition duckdb.cpp:73983

◆ GetProgress()

idx_t duckdb::FileHandle::GetProgress ( )
virtual
74409 {
74410 throw NotImplementedException("GetProgress is not implemented for this file handle");
74411}

◆ GetFileCompressionType()

FileCompressionType duckdb::FileHandle::GetFileCompressionType ( )
virtual
74332 {
74333 return FileCompressionType::UNCOMPRESSED;
74334}

◆ CanSeek()

bool duckdb::FileHandle::CanSeek ( )
74328 {
74329 return file_system.CanSeek();
74330}
virtual DUCKDB_API bool CanSeek()
Whether or not we can seek into the file.
Definition duckdb.cpp:74244

◆ IsPipe()

bool duckdb::FileHandle::IsPipe ( )
74336 {
74337 return file_system.IsPipe(path);
74338}
virtual DUCKDB_API bool IsPipe(const string &filename, optional_ptr< FileOpener > opener=nullptr)
Check if path is pipe.
Definition duckdb.cpp:74104

◆ OnDiskFile()

bool duckdb::FileHandle::OnDiskFile ( )
74368 {
74369 return file_system.OnDiskFile(*this);
74370}
virtual DUCKDB_API bool OnDiskFile(FileHandle &handle)
Definition duckdb.cpp:74256

◆ GetFileSize()

idx_t duckdb::FileHandle::GetFileSize ( )
74372 {
74373 return NumericCast<idx_t>(file_system.GetFileSize(*this));
74374}
virtual DUCKDB_API int64_t GetFileSize(FileHandle &handle)
Returns the file size of a file handle, returns -1 on error.
Definition duckdb.cpp:73988

◆ GetType()

FileType duckdb::FileHandle::GetType ( )
74384 {
74385 return file_system.GetFileType(*this);
74386}
virtual DUCKDB_API FileType GetFileType(FileHandle &handle)
Returns the file type of the attached handle.
Definition duckdb.cpp:74001

◆ Stats()

FileMetadata duckdb::FileHandle::Stats ( )
74388 {
74389 return file_system.Stats(*this);
74390}
virtual DUCKDB_API FileMetadata Stats(FileHandle &handle)
Returns the file stats of the attached handle.
Definition duckdb.cpp:74005

◆ TryAddLogger()

void duckdb::FileHandle::TryAddLogger ( FileOpener opener)
74392 {
74393 if (flags.DisableLogging()) {
74394 return;
74395 }
74396
74397 auto context = opener.TryGetClientContext();
74398 if (context && Logger::Get(*context).ShouldLog(FileSystemLogType::NAME, FileSystemLogType::LEVEL)) {
74399 logger = context->logger;
74400 return;
74401 }
74402
74403 auto database = opener.TryGetDatabase();
74404 if (database && Logger::Get(*database).ShouldLog(FileSystemLogType::NAME, FileSystemLogType::LEVEL)) {
74405 logger = database->GetLogManager().GlobalLoggerReference();
74406 }
74407}

◆ Close()

virtual DUCKDB_API void duckdb::FileHandle::Close ( )
pure virtual

Closes the file handle.

Implemented in duckdb::CompressedFile, and duckdb::UnixFileHandle.

◆ GetPath()

string duckdb::FileHandle::GetPath ( ) const
inline
8178 {
8179 return path;
8180 }

◆ GetFlags()

FileOpenFlags duckdb::FileHandle::GetFlags ( ) const
inline
8182 {
8183 return flags;
8184 }

◆ Cast() [1/2]

template<class TARGET >
TARGET & duckdb::FileHandle::Cast ( )
inline
8187 {
8188 DynamicCastCheck<TARGET>(this);
8189 return reinterpret_cast<TARGET &>(*this);
8190 }

◆ Cast() [2/2]

template<class TARGET >
const TARGET & duckdb::FileHandle::Cast ( ) const
inline
8192 {
8193 DynamicCastCheck<TARGET>(this);
8194 return reinterpret_cast<const TARGET &>(*this);
8195 }

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