Input and output streams are exposed by DataStore
instances via open_read
and open_write
functions. They allow data to be read from or written to a data store in binary form. Depending on the data store a stream can be seekable and can support zero-copy reading/writing.
Reads data from an underlying DataStore
instance. An InputStream
instance is usually retrieved by calling the open_read
method of a data store.
Expects the caller to provide a writable Python object that supports the Python Buffer protocol (e.g. array.array
). It fills the specified buffer with data read from the underlying data store and returns the number of bytes read.
read(buf : Buffer)
buf
: A writable Python object that supports the Python Buffer protocol
Seeks to the specified position in the stream.
seek(pos : int)
pos
: The new position in the stream
Closes the input stream.
close()
InputStream
supports the context manager protocol and can be automatically closed via a with
statement.
Gets the size of the stream. Only supported by seekable streams; otherwise, raises a NotSupportedError
.
Gets a boolean value indicating whether the stream is seekable.
Gets a boolean value indicating whether the stream supports zero-copy reading.
Gets a boolean value indicating whether the stream is closed.
Not implemented yet
Type | Description |
---|---|
StreamError |
Thrown when the stream cannot be read. Inherits from MLIOError . |
InflateError |
Thrown when the stream cannot be decompressed. Inherits from StreamError . |