OpenZGY/Python API and Internals (ALPHA)
Access seismic data stored in ZGY format.
Public Member Functions | List of all members
openzgy.impl.file.SeismicStoreFileDelayedWrite Class Reference
Inheritance diagram for openzgy.impl.file.SeismicStoreFileDelayedWrite:
openzgy.impl.file.FileADT

Public Member Functions

def __init__ (self, filename, mode, iocontext)
 
def __enter__ (self)
 
def __exit__ (self, type, value, traceback)
 
def xx_eof (self)
 
def xx_write (self, data, offset, *usagehint=UsageHint.Unknown)
 
def xx_read (self, offset, size, *usagehint=UsageHint.Unknown)
 
def xx_readv (self, requests, *parallel_ok=False, immutable_ok=False, transient_ok=False, usagehint=UsageHint.Unknown, **kwargs)
 
def xx_close (self)
 
def threadsafe (self)
 
def xx_iscloud (self)
 
- Public Member Functions inherited from openzgy.impl.file.FileADT
def xx_readv (self, requests, *parallel_ok=False, immutable_ok=False, transient_ok=False, usagehint=UsageHint.Unknown)
 

Detailed Description

Improve on SeismicStoreFile, have it buffer large chunks of data before
writing it out to a new segment.

  * Writes starting at EOF are allowed, and will buffer data in the
   "open segment" until explicitly flushed.

  * Writes starting past EOF, signifying a hole in the data, are not
   allowed.

  * Writes fully inside the open segment are allowed.

  * Writes starting before the open segment are only allowed if
    offset,size exactly matches a previous write. This will cause that
    segment to be rewritten. As a corollary, writes canot span the
    closed segment / open segment boundary.

  * Possible future extension: For the  last segment only offset
    needs to match. This means the last segment may be resized.
    Why we might want this: On opening a file with existing
    data bricks we might choose to read the last segment and
    turn it into an open segment. Then delete (in memory only)
    the last segment. When it is time to flush the data it gets
    rewritten. This allows adding bricks to a file, while still
    ensuring that all segments except first and last need to be
    the same size. Note that there are other tasks such as
    incrementally updating statistics and histogram that might
    turn out to be a lot of work.

  * When used to create ZGY files, caller must honor the convention
    that all segments except the first and last must have the same size.

  * Caveat: The fact that random writes are sometimes allowed, sometimes
    not depending on the segment number violates the principle of
    least surprise. And makes for more elaborate testing. For ZGY
    it is quite useful though. ZGY can recover from a ZgySegmentIsClosed
    exception by abandoning (leaking) the current block and write it
    to a new location. With a typical access pattern this will happen
    only occasionally.

Constructor & Destructor Documentation

◆ __init__()

def openzgy.impl.file.SeismicStoreFileDelayedWrite.__init__ (   self,
  filename,
  mode,
  iocontext 
)
Open a file in the specified mode, which must be "rb" or "w+b".
Caller should use a "with" block to ensure the file gets closed.
The iocontext is an optional data structure that the user may
specify when a reader is created. It might be used to hold
user credentials etc. needed to access the low level file.
TODO-Low: support "r+b" (update) at some point in the future.

Reimplemented from openzgy.impl.file.FileADT.

Member Function Documentation

◆ xx_close()

def openzgy.impl.file.SeismicStoreFileDelayedWrite.xx_close (   self)
Close a previously opened file.
No action if the file is already closed.

Reimplemented from openzgy.impl.file.FileADT.

◆ xx_eof()

def openzgy.impl.file.SeismicStoreFileDelayedWrite.xx_eof (   self)
Current size of the zgy file, including any buffered unwritten data.

◆ xx_read()

def openzgy.impl.file.SeismicStoreFileDelayedWrite.xx_read (   self,
  offset,
  size,
usagehint = UsageHint.Unknown 
)
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.

Reimplemented from openzgy.impl.file.FileADT.

◆ xx_write()

def openzgy.impl.file.SeismicStoreFileDelayedWrite.xx_write (   self,
  data,
  offset,
usagehint = UsageHint.Unknown 
)
Write data to seismic store, buffering the writes to get larger
segment sizes. Writes are only allowed at offset 0 and at EOF.
This is less general then the parent type which lets us rewrite
any segment as long as its size does not change.

Segment 0 contains just the headers and is always written in one
operation, so this is not buffered. Segment 0 can be both smaller
and larger than segsize. Which is another reason to bypass the
buffering code. Also, if we are rewriting data we bypass the
buffering and require that the caller updates the entire segment.
ZGY will currently only rewrite segment 0.

If segsize is zero no buffering is done and each write will either
create a new segment or completely rewrite an existing segment.

Reimplemented from openzgy.impl.file.FileADT.


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