OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | Static Public Member Functions | List of all members
InternalZGY::LocalFileLinux Class Reference
Inheritance diagram for InternalZGY::LocalFileLinux:
InternalZGY::FileCommon InternalZGY::FileADT

Public Member Functions

 LocalFileLinux (const std::string &filename, OpenMode mode, const OpenZGY::IOContext *iocontext)
 
virtual void xx_close () override
 
virtual std::int64_t xx_eof () const override
 
virtual bool xx_iscloud () const override
 
virtual void xx_read (void *data, std::int64_t offset, std::int64_t size, UsageHint usagehint=UsageHint::Unknown) override
 
virtual void xx_readv (const ReadList &requests, bool parallel_ok=false, bool immutable_ok=false, bool transient_ok=false, UsageHint usagehint=UsageHint::Unknown) override
 
virtual void xx_write (const void *data, std::int64_t offset, std::int64_t size, UsageHint usagehint=UsageHint::Unknown) override
 
virtual bool xx_threadsafe () const override
 
virtual std::int64_t _real_eof () const
 Get the current file size for error reporting. More...
 
- Public Member Functions inherited from InternalZGY::FileCommon
 FileCommon (const std::string &filename, OpenMode mode, const OpenZGY::IOContext *iocontext)
 
virtual void _check_short_read (std::int64_t offset, std::int64_t size, std::int64_t got) const
 Throw a descriptive error if there was something wrong with the read. More...
 

Static Public Member Functions

static std::shared_ptr< FileADTxx_make_instance (const std::string &filename, OpenMode mode, const OpenZGY::IOContext *iocontext)
 
- Static Public Member Functions inherited from InternalZGY::FileADT
static std::shared_ptr< FileADTfactory (const std::string &filename, OpenMode mode, const OpenZGY::IOContext *iocontext)
 

Additional Inherited Members

- Static Protected Member Functions inherited from InternalZGY::FileADT
static std::string _nice (std::int64_t n)
 Human readable number.
 
static void _validate_read (void *data, std::int64_t offset, std::int64_t size, std::int64_t eof, OpenMode mode)
 
static void _validate_write (const void *data, std::int64_t offset, std::int64_t size, OpenMode mode)
 
static void _validate_readv (const ReadList &requests, std::int64_t eof, OpenMode mode)
 
- Protected Attributes inherited from InternalZGY::FileCommon
FileConfig _config
 
OpenMode _mode
 
std::string _name
 
std::int64_t _eof
 
std::shared_ptr< SummaryTimer_rtimer
 
std::shared_ptr< SummaryTimer_wtimer
 

Member Function Documentation

◆ _real_eof()

std::int64_t InternalZGY::LocalFileLinux::_real_eof ( ) const
virtual

Get the current file size for error reporting.

The default implementation in the base class just assumes that the xx_eof() that is (probably) maintained internally is correct.

Reimplemented from InternalZGY::FileCommon.

◆ xx_close()

void InternalZGY::LocalFileLinux::xx_close ( )
overridevirtual

Close the file. This should always be done explicitly instead of assuming the destructor will handle it. If left to the destructor then any exceptions will be swallowed.

Implements InternalZGY::FileADT.

◆ xx_eof()

std::int64_t InternalZGY::LocalFileLinux::xx_eof ( ) const
overridevirtual

Return the current end-of-file, i.e. the file size.

Implements InternalZGY::FileADT.

◆ xx_iscloud()

bool InternalZGY::LocalFileLinux::xx_iscloud ( ) const
overridevirtual

Return true if the file is on the cloud. This might trigger some optimizations.

Implements InternalZGY::FileADT.

◆ xx_read()

void InternalZGY::LocalFileLinux::xx_read ( void *  data,
std::int64_t  offset,
std::int64_t  size,
UsageHint  usagehint = UsageHint::Unknown 
)
overridevirtual

Read binary data from the file. Both size and offset are mandatory. I.e. caller is not allowed to read "the entire file", and not allowed to "read from where I left off the last time". The actual reading will be done in a derived class. The base class only validates the arguments.

Implements InternalZGY::FileADT.

◆ xx_readv()

void InternalZGY::LocalFileLinux::xx_readv ( const ReadList &  requests,
bool  parallel_ok = false,
bool  immutable_ok = false,
bool  transient_ok = false,
UsageHint  usagehint = UsageHint::Unknown 
)
overridevirtual

Read binary data from multiple regions in the file. Each part of the request specifies offset, size, and a delivery functor which will be invoked to pass back the returned bulk.

Arguments: parallel_ok: If true then the delivery functor might be called simultaneously from multiple worker threads. The function itself will block until all the data has been read or an error occurs. immutable_ok: If true the caller promises that the delivery functor will not try to modify the data buffer. Pass False e.g. if the functor may need to byteswap the data it has read from file. transient_ok: If true the caller promises that the delivery functor will not keep a reference to the data buffer after the functor returns.

The delivery functor is called as fn(void* data, std::int64_t size)

FUTURE: a new argument partial_ok may be set to True if it is ok to call the delivery functor with less data than requested, and to keep calling it until all data has been delivered. The signature of the delivery functor gets changed to fn(data, offset, size). Offset is the absolute file offset. I.e. not relative to the requested offset. Passing partial_ok=True might elide some buffer copies if the caller is doing something simple (such as reading an uncompressed brick) where partial copies are possible, and the backend is in the cloud, and a longer lived cache is being maintained, and the cache block size is smaller than the requested size. That is a lot of ifs. There was some code to handle partial_ok but it has been removed. Get it from the git history if you really want it.

Implements InternalZGY::FileADT.

◆ xx_threadsafe()

bool InternalZGY::LocalFileLinux::xx_threadsafe ( ) const
overridevirtual

Return true if multiple reads can be in progress at the same time.

Implements InternalZGY::FileADT.

◆ xx_write()

void InternalZGY::LocalFileLinux::xx_write ( const void *  data,
std::int64_t  offset,
std::int64_t  size,
UsageHint  usagehint = UsageHint::Unknown 
)
overridevirtual

Write binary data to the file. Offset is mandatory. I.e. caller is not allowed to "write to where I left off the last time". The actual writing will be done in a derived class. The base class only validates the arguments.

Implements InternalZGY::FileADT.


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