BarecatReadWriteFileObject#

class barecat.io.fileobj.BarecatReadWriteFileObject(shard_file, offset, size, on_close_callback, mode='r+b')[source]#

Bases: BarecatFileObject

File-like object for writing to a barecat file with spillover support.

  • Writes within original bounds go directly to shard

  • Writes beyond original bounds go to spillover (temp file)

Parameters:
  • shard_file (FileIO) – file-like object representing the shard where the file lives

  • offset (int) – offset of the file within the shard

  • size (int) – original size of the file

  • on_close_callback (Callable[[BarecatReadWriteFileObject], None]) – callback function to be called on close, arg has to be self

  • mode (str) – file mode string

Instance Methods#

tell()

Return current stream position.

seek(offset[, whence])

Change stream position.

truncate([size])

Truncate file to size bytes.

readable()

Return whether object was opened for reading.

writable()

Return whether object was opened for writing.

seekable()

Return whether object supports random access.

flush()

Flush write buffers, if applicable.

close()

Flush and close the IO object.