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

Public Member Functions

virtual void xx_read (void *data, std::int64_t offset, std::int64_t size, UsageHint usagehint=UsageHint::Unknown)=0
 
virtual void xx_readv (const ReadList &requests, bool parallel_ok=false, bool immutable_ok=false, bool transient_ok=false, UsageHint usagehint=UsageHint::Unknown)=0
 
virtual void xx_write (const void *data, std::int64_t offset, std::int64_t size, UsageHint usagehint=UsageHint::Unknown)=0
 
virtual void xx_close ()=0
 
virtual std::int64_t xx_eof () const =0
 
virtual bool xx_threadsafe () const =0
 
virtual bool xx_iscloud () const =0
 

Static Public Member Functions

static std::shared_ptr< FileADTfactory (const std::string &filename, OpenMode mode, const OpenZGY::IOContext *iocontext)
 

Static Protected Member Functions

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)
 

Member Function Documentation

◆ xx_close()

void InternalZGY::FileADT::xx_close ( )
pure virtual

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.

Implemented in InternalZGY::LocalFileLinux.

◆ xx_eof()

virtual std::int64_t InternalZGY::FileADT::xx_eof ( ) const
pure virtual

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

Implemented in InternalZGY::LocalFileLinux.

◆ xx_iscloud()

virtual bool InternalZGY::FileADT::xx_iscloud ( ) const
pure virtual

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

Implemented in InternalZGY::LocalFileLinux.

◆ xx_read()

virtual void InternalZGY::FileADT::xx_read ( void *  data,
std::int64_t  offset,
std::int64_t  size,
UsageHint  usagehint = UsageHint::Unknown 
)
pure virtual

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.

Implemented in InternalZGY::LocalFileLinux.

◆ xx_readv()

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

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.

Implemented in InternalZGY::LocalFileLinux.

◆ xx_threadsafe()

virtual bool InternalZGY::FileADT::xx_threadsafe ( ) const
pure virtual

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

Implemented in InternalZGY::LocalFileLinux.

◆ xx_write()

virtual void InternalZGY::FileADT::xx_write ( const void *  data,
std::int64_t  offset,
std::int64_t  size,
UsageHint  usagehint = UsageHint::Unknown 
)
pure virtual

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.

Implemented in InternalZGY::LocalFileLinux.


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